Exact match queries

Perform simple exact match queries

An exact match query allows you to select all documents where a field matches a specific value.

You can use exact match queries on several field types. The query syntax varies depending on the type.

The examples in this article use a schema with the following fields:

Field name Field type
description TEXT
condition TAG

You can find more details about creating the index and loading the demo data in the quick start guide.

Numeric field

To perform an exact match query on a numeric field, you need to construct a range query with the same start and end value:

FT.SEARCH index "@field:[value value]"


FT.SEARCH index "@field:[value]" DIALECT 2


FT.SEARCH index "@field==value" DIALECT 2

As described in the article about range queries, you can also use the FILTER argument:

FT.SEARCH index "*" FILTER field start end

The following examples show you how to query for bicycles with a price of exactly 270 USD:

FT.SEARCH idx:bicycle "@price:[270 270]"
FT.SEARCH idx:bicycle "@price:[270]"
FT.SEARCH idx:bicycle "@price==270"
FT.SEARCH idx:bicycle "*" FILTER price 270 270

Tag field

A tag is a short sequence of text, for example, "new" or "Los Angeles".

If you need to query for short texts, use a tag query instead of a full-text query. Tag fields are more space-efficient for storing index entries and often lead to lower query complexity for exact match queries.

You can construct a tag query for a single tag in the following way:

FT.SEARCH index "@field:{tag}"
The curly brackets are mandatory for tag queries.

This short example shows you how to query for new bicycles:

FT.SEARCH idx:bicycle "@condition:{new}"

Use double quotes and DIALECT 2 for exact match queries involving tags that contain special characters. The only character that needs escaping in queries involving double-quoted tags is the double-quote character. Here's an example of using double-quoted tags that contain special characters:

JSON.SET key:1 $ '{"email": "test@redis.com"}'
FT.CREATE idx ON JSON PREFIX 1 key: SCHEMA $.email AS email TAG

FT.SEARCH idx '@email:{"test@redis.com"}' DIALECT 2

Full-text field

A detailed explanation of full-text queries is available in the full-text queries documentation. You can also query for an exact match of a phrase within a text field:

FT.SEARCH index "@field:\"phrase\""

The phrase must be wrapped by escaped double quotes for an exact match query.

You can't use a phrase that starts with a stop word.

Here is an example for finding all bicycles that have a description containing the exact text 'rough terrain':

FT.SEARCH idx:bicycle "@description:\"rough terrain\""
Back to top ↑