K - Key type.V - Value type.public interface RediSearchAsyncCommands<K,V>
| Modifier and Type | Method and Description |
|---|---|
RedisFuture<AggregationReply<K,V>> |
ftAggregate(String index,
V query)
Run a search query on an index and perform basic aggregate transformations using default options.
|
RedisFuture<AggregationReply<K,V>> |
ftAggregate(String index,
V query,
AggregateArgs<K,V> args)
Run a search query on an index and perform advanced aggregate transformations with a processing pipeline.
|
RedisFuture<String> |
ftAliasadd(String alias,
String index)
Add an alias to a search index.
|
RedisFuture<String> |
ftAliasdel(String alias)
Remove an alias from a search index.
|
RedisFuture<String> |
ftAliasupdate(String alias,
String index)
Update an existing alias to point to a different search index.
|
RedisFuture<String> |
ftAlter(String index,
boolean skipInitialScan,
List<FieldArgs<K>> fieldArgs)
Add new attributes to an existing search index.
|
RedisFuture<String> |
ftAlter(String index,
List<FieldArgs<K>> fieldArgs)
Add new attributes to an existing search index.
|
RedisFuture<String> |
ftCreate(String index,
CreateArgs<K,V> arguments,
List<FieldArgs<K>> fieldArgs)
Create a new search index with the given name, custom configuration, and field definitions.
|
RedisFuture<String> |
ftCreate(String index,
List<FieldArgs<K>> fieldArgs)
Create a new search index with the given name and field definitions using default settings.
|
RedisFuture<String> |
ftCursordel(String index,
AggregationReply.Cursor cursor)
Delete a cursor and free its associated resources.
|
RedisFuture<AggregationReply<K,V>> |
ftCursorread(String index,
AggregationReply.Cursor cursor)
Read next results from an existing cursor using the default batch size.
|
RedisFuture<AggregationReply<K,V>> |
ftCursorread(String index,
AggregationReply.Cursor cursor,
int count)
Read next results from an existing cursor and optionally override the batch size.
|
RedisFuture<Long> |
ftDictadd(String dict,
V... terms)
Add terms to a dictionary.
|
RedisFuture<Long> |
ftDictdel(String dict,
V... terms)
Delete terms from a dictionary.
|
RedisFuture<List<V>> |
ftDictdump(String dict)
Dump all terms in a dictionary.
|
RedisFuture<String> |
ftDropindex(String index)
Drop a search index without deleting the associated documents.
|
RedisFuture<String> |
ftDropindex(String index,
boolean deleteDocuments)
Drop a search index with optional document deletion.
|
RedisFuture<String> |
ftExplain(String index,
V query)
Return the execution plan for a complex query.
|
RedisFuture<String> |
ftExplain(String index,
V query,
ExplainArgs<K,V> args)
Return the execution plan for a complex query with additional options.
|
RedisFuture<List<V>> |
ftList()
Return a list of all existing indexes.
|
RedisFuture<SearchReply<K,V>> |
ftSearch(String index,
V query)
Search the index with a textual query using default search options.
|
RedisFuture<SearchReply<K,V>> |
ftSearch(String index,
V query,
SearchArgs<K,V> args)
Search the index with a textual query using advanced search options and filters.
|
RedisFuture<SpellCheckResult<V>> |
ftSpellcheck(String index,
V query)
Perform spelling correction on a query, returning suggestions for misspelled terms.
|
RedisFuture<SpellCheckResult<V>> |
ftSpellcheck(String index,
V query,
SpellCheckArgs<K,V> args)
Perform spelling correction on a query with additional options.
|
RedisFuture<Long> |
ftSugadd(K key,
V suggestion,
double score)
Add a suggestion string to an auto-complete suggestion dictionary.
|
RedisFuture<Long> |
ftSugadd(K key,
V suggestion,
double score,
SugAddArgs<K,V> args)
Add a suggestion string to an auto-complete suggestion dictionary with additional options.
|
RedisFuture<Boolean> |
ftSugdel(K key,
V suggestion)
Delete a string from a suggestion dictionary.
|
RedisFuture<List<Suggestion<V>>> |
ftSugget(K key,
V prefix)
Get completion suggestions for a prefix.
|
RedisFuture<List<Suggestion<V>>> |
ftSugget(K key,
V prefix,
SugGetArgs<K,V> args)
Get completion suggestions for a prefix with additional options.
|
RedisFuture<Long> |
ftSuglen(K key)
Get the size of an auto-complete suggestion dictionary.
|
RedisFuture<Map<V,List<V>>> |
ftSyndump(String index)
Dump synonym group contents.
|
RedisFuture<String> |
ftSynupdate(String index,
V synonymGroupId,
SynUpdateArgs<K,V> args,
V... terms)
Update a synonym group with additional terms and options.
|
RedisFuture<String> |
ftSynupdate(String index,
V synonymGroupId,
V... terms)
Update a synonym group with additional terms.
|
RedisFuture<List<V>> |
ftTagvals(String index,
String fieldName)
Return a distinct set of values indexed in a Tag field.
|
@Experimental RedisFuture<String> ftCreate(String index, List<FieldArgs<K>> fieldArgs)
This command creates a new search index that enables full-text search, filtering, and aggregation capabilities on Redis data structures. The index will use default settings for data type (HASH), key prefixes (all keys), and other configuration options.
Time complexity: O(K) at creation where K is the number of fields, O(N) if scanning the keyspace is triggered, where N is the number of keys in the keyspace
index - the index namefieldArgs - the FieldArgs list defining the searchable fields and their types"OK" if the index was created successfullyCreateArgs,
FieldArgs,
ftCreate(String, CreateArgs, List),
ftDropindex(String)@Experimental RedisFuture<String> ftCreate(String index, CreateArgs<K,V> arguments, List<FieldArgs<K>> fieldArgs)
This command creates a new search index with advanced configuration options that control how the index behaves, what data it indexes, and how it processes documents. This variant provides full control over index creation parameters.
The CreateArgs parameter allows you to specify:
Time complexity: O(K) at creation where K is the number of fields, O(N) if scanning the keyspace is triggered, where N is the number of keys in the keyspace
index - the index namearguments - the index CreateArgs containing configuration optionsfieldArgs - the FieldArgs list defining the searchable fields and their types"OK" if the index was created successfullyCreateArgs,
FieldArgs,
ftCreate(String, List),
ftDropindex(String)@Experimental RedisFuture<String> ftAliasadd(String alias, String index)
This command creates an alias that points to an existing search index, allowing applications to reference the index by an alternative name. Aliases provide a level of indirection that enables transparent index management and migration strategies.
Key features and use cases:
Important notes:
ftAliasupdate(String, String) to reassign an existing aliasTime complexity: O(1)
alias - the alias name to createindex - the target index name that the alias will point to"OK" if the alias was successfully createdftAliasupdate(String, String),
ftAliasdel(String)@Experimental RedisFuture<String> ftAliasupdate(String alias, String index)
This command updates an existing alias to point to a different index, or creates the alias if it doesn't exist. Unlike
ftAliasadd(String, String), this command will succeed even if the alias already exists, making it useful for
atomic alias updates during index migrations.
Key features and use cases:
Important notes:
ftAliasadd)Time complexity: O(1)
alias - the alias name to update or createindex - the target index name that the alias will point to"OK" if the alias was successfully updatedftAliasadd(String, String),
ftAliasdel(String)@Experimental RedisFuture<String> ftAliasdel(String alias)
This command removes an existing alias, breaking the association between the alias name and its target index. The underlying index remains unchanged and accessible by its original name.
Key features and use cases:
Important notes:
ftAliasupdate(String, String) to redirect before deletionTime complexity: O(1)
alias - the alias name to remove"OK" if the alias was successfully removedftAliasadd(String, String),
ftAliasupdate(String, String)@Experimental RedisFuture<String> ftAlter(String index, boolean skipInitialScan, List<FieldArgs<K>> fieldArgs)
This command allows you to extend an existing search index by adding new searchable fields without recreating the entire index. The new attributes will be applied to future document updates and can optionally be applied to existing documents through reindexing.
Key features and considerations:
Important notes:
MAXTEXTFIELDS, you may be limited to 32 total text attributesSKIPINITIALSCAN to avoid scanning existing documents if immediate indexing is not required
Time complexity: O(N) where N is the number of keys in the keyspace if initial scan is performed, O(1)
if SKIPINITIALSCAN is used
index - the index name, as a keyskipInitialScan - if true, skip scanning and indexing existing documents; if false, scan and index
existing documents with the new attributesfieldArgs - the FieldArgs list defining the new searchable fields and their types to add"OK" if the index was successfully alteredFieldArgs,
ftCreate(String, List),
ftCreate(String, CreateArgs, List)@Experimental RedisFuture<String> ftAlter(String index, List<FieldArgs<K>> fieldArgs)
This command allows you to extend an existing search index by adding new searchable fields without recreating the entire index. The new attributes will be applied to future document updates and can optionally be applied to existing documents through reindexing.
Key features and considerations:
Time complexity: O(N) where N is the number of keys in the keyspace if initial scan is performed
index - the index name, as a keyfieldArgs - the FieldArgs list defining the new searchable fields and their types to add"OK" if the index was successfully alteredFieldArgs,
ftCreate(String, List),
ftCreate(String, CreateArgs, List)@Experimental RedisFuture<List<V>> ftTagvals(String index, String fieldName)
This command retrieves all unique values that have been indexed in a specific Tag field within a search index. It's particularly useful for discovering the range of values available in categorical fields such as cities, categories, status values, or any other enumerated data.
Key features and use cases:
Important limitations:
Example usage scenarios:
Time complexity: O(N) where N is the number of distinct values in the tag field
index - the index name containing the tag fieldfieldName - the name of the Tag field defined in the index schemaftCreate(String, List),
ftCreate(String, CreateArgs, List)@Experimental RedisFuture<SpellCheckResult<V>> ftSpellcheck(String index, V query)
This command analyzes the query for misspelled terms and provides spelling suggestions based on the indexed terms and optionally custom dictionaries. A misspelled term is a full text term (word) that is:
Key features and use cases:
Time complexity: O(1)
index - the index with the indexed termsquery - the search query to check for spelling errorsftSpellcheck(String, Object, SpellCheckArgs),
ftDictadd(String, Object[]),
ftDictdel(String, Object[]),
ftDictdump(String)@Experimental RedisFuture<SpellCheckResult<V>> ftSpellcheck(String index, V query, SpellCheckArgs<K,V> args)
This command analyzes the query for misspelled terms and provides spelling suggestions with configurable options for distance, custom dictionaries, and dialect.
Available options:
Time complexity: O(1)
index - the index with the indexed termsquery - the search query to check for spelling errorsargs - the spellcheck arguments (distance, terms, dialect)ftSpellcheck(String, Object),
ftDictadd(String, Object[]),
ftDictdel(String, Object[]),
ftDictdump(String)@Experimental RedisFuture<Long> ftDictadd(String dict, V... terms)
This command adds one or more terms to a dictionary. Dictionaries are used for storing custom stopwords, synonyms, and other term lists that can be referenced in search operations. The dictionary is created if it doesn't exist.
Key features and use cases:
Time complexity: O(1)
dict - the dictionary nameterms - the terms to add to the dictionaryftDictdel(String, Object[]),
ftDictdump(String)@Experimental RedisFuture<Long> ftDictdel(String dict, V... terms)
This command removes one or more terms from a dictionary. Only exact matches will be removed from the dictionary. Non-existent terms are ignored.
Time complexity: O(1)
dict - the dictionary nameterms - the terms to delete from the dictionaryftDictadd(String, Object[]),
ftDictdump(String)@Experimental RedisFuture<List<V>> ftDictdump(String dict)
This command returns all terms stored in the specified dictionary. The terms are returned in no particular order.
Time complexity: O(N), where N is the size of the dictionary
dict - the dictionary nameftDictadd(String, Object[]),
ftDictdel(String, Object[])@Experimental RedisFuture<String> ftExplain(String index, V query)
This command returns a string representing the execution plan that Redis Search will use to execute the given query. This is useful for understanding how the query will be processed and for optimizing query performance.
Key features and use cases:
Time complexity: O(1)
index - the index namequery - the search query to explainftExplain(String, Object, ExplainArgs),
ftSearch(String, Object)@Experimental RedisFuture<String> ftExplain(String index, V query, ExplainArgs<K,V> args)
This command returns a string representing the execution plan that Redis Search will use to execute the given query under the specified dialect version.
Available options:
Time complexity: O(1)
index - the index namequery - the search query to explainargs - the explain arguments (dialect)ftExplain(String, Object),
ftSearch(String, Object)@Experimental RedisFuture<List<V>> ftList()
This command returns an array with the names of all existing indexes in the database. This is useful for discovering available indexes and managing index lifecycle.
Key features and use cases:
Time complexity: O(1)
Note: This is a temporary command (indicated by the underscore prefix). In the future, a SCAN-type command will be added for use when a database contains a large number of indices.
#ftCreate(String, CreateArgs, FieldArgs[]),
ftDropindex(String)@Experimental RedisFuture<Map<V,List<V>>> ftSyndump(String index)
This command returns the contents of a synonym group. Synonym groups are used to define terms that should be treated as equivalent during search operations.
Key features and use cases:
Time complexity: O(1)
index - the index nameftSynupdate(String, Object, Object[]),
ftSynupdate(String, Object, SynUpdateArgs, Object[])@Experimental RedisFuture<String> ftSynupdate(String index, V synonymGroupId, V... terms)
This command creates or updates a synonym group with the specified terms. All terms in a synonym group are treated as equivalent during search operations. The command triggers a scan of all documents by default.
Key features and use cases:
Time complexity: O(1)
index - the index namesynonymGroupId - the synonym group identifierterms - the terms to add to the synonym groupftSynupdate(String, Object, SynUpdateArgs, Object[]),
ftSyndump(String)@Experimental RedisFuture<String> ftSynupdate(String index, V synonymGroupId, SynUpdateArgs<K,V> args, V... terms)
This command creates or updates a synonym group with the specified terms and options. The SKIPINITIALSCAN option can be used to avoid scanning existing documents, affecting only documents indexed after the update.
Available options:
Time complexity: O(1)
index - the index namesynonymGroupId - the synonym group identifierargs - the synupdate arguments (skipInitialScan)terms - the terms to add to the synonym groupftSynupdate(String, Object, Object[]),
ftSyndump(String)@Experimental RedisFuture<Long> ftSugadd(K key, V suggestion, double score)
This command adds a suggestion string to an auto-complete suggestion dictionary with a specified score. The auto-complete suggestion dictionary is disconnected from the index definitions and leaves creating and updating suggestions dictionaries to the user.
Key features and use cases:
Time complexity: O(1)
key - the suggestion dictionary keysuggestion - the suggestion string to indexscore - the floating point number of the suggestion string's weightftSugadd(Object, Object, double, SugAddArgs),
ftSugget(Object, Object),
ftSugdel(Object, Object),
ftSuglen(Object)@Experimental RedisFuture<Long> ftSugadd(K key, V suggestion, double score, SugAddArgs<K,V> args)
This command adds a suggestion string to an auto-complete suggestion dictionary with a specified score and optional arguments for incremental updates and payload storage.
Time complexity: O(1)
key - the suggestion dictionary keysuggestion - the suggestion string to indexscore - the floating point number of the suggestion string's weightargs - the suggestion add arguments (INCR, PAYLOAD)ftSugadd(Object, Object, double),
ftSugget(Object, Object, SugGetArgs),
ftSugdel(Object, Object),
ftSuglen(Object)@Experimental RedisFuture<Boolean> ftSugdel(K key, V suggestion)
This command removes a suggestion string from an auto-complete suggestion dictionary. Only the exact string match will be removed from the dictionary.
Time complexity: O(1)
key - the suggestion dictionary keysuggestion - the suggestion string to deletetrue if the string was found and deleted, false otherwiseftSugadd(Object, Object, double),
ftSugget(Object, Object),
ftSuglen(Object)@Experimental RedisFuture<List<Suggestion<V>>> ftSugget(K key, V prefix)
This command retrieves completion suggestions for a prefix from an auto-complete suggestion dictionary. By default, it returns up to 5 suggestions that match the given prefix.
Time complexity: O(1)
key - the suggestion dictionary keyprefix - the prefix to complete onftSugget(Object, Object, SugGetArgs),
ftSugadd(Object, Object, double),
ftSugdel(Object, Object),
ftSuglen(Object)@Experimental RedisFuture<List<Suggestion<V>>> ftSugget(K key, V prefix, SugGetArgs<K,V> args)
This command retrieves completion suggestions for a prefix from an auto-complete suggestion dictionary with optional arguments for fuzzy matching, score inclusion, payload inclusion, and result limiting.
Time complexity: O(1)
key - the suggestion dictionary keyprefix - the prefix to complete onargs - the suggestion get arguments (FUZZY, WITHSCORES, WITHPAYLOADS, MAX)ftSugget(Object, Object),
ftSugadd(Object, Object, double, SugAddArgs),
ftSugdel(Object, Object),
ftSuglen(Object)@Experimental RedisFuture<Long> ftSuglen(K key)
This command returns the current number of suggestions stored in the auto-complete suggestion dictionary.
Time complexity: O(1)
key - the suggestion dictionary keyftSugadd(Object, Object, double),
ftSugget(Object, Object),
ftSugdel(Object, Object)@Experimental RedisFuture<String> ftDropindex(String index)
This command removes the search index and all its associated metadata, but preserves the original documents (hashes or JSON objects) that were indexed. This is the safe default behavior that allows you to recreate the index later without losing data.
Time complexity: O(1)
index - the index name, as a key"OK" if the index was successfully droppedftDropindex(String, boolean),
ftCreate(String, List)@Experimental RedisFuture<String> ftDropindex(String index, boolean deleteDocuments)
This command removes the search index and optionally deletes all associated documents. When deleteDocuments is
true, this operation becomes destructive and will permanently remove both the index and all indexed documents
from Redis.
Asynchronous Behavior: If an index creation is still running (ftCreate(String, List) is running
asynchronously), only the document hashes that have already been indexed are deleted. Documents that are queued for
indexing but not yet processed will remain in the database.
Time complexity: O(1) or O(N) if documents are deleted, where N is the number of keys in the keyspace
index - the index name, as a keydeleteDocuments - if true, delete the indexed documents as well; if false, preserve documents"OK" if the index was successfully droppedftDropindex(String),
ftCreate(String, List)@Experimental RedisFuture<SearchReply<K,V>> ftSearch(String index, V query)
This command performs a full-text search on the specified index using the provided query string. It returns matching documents with their content and metadata. This is the basic search variant that uses default search behavior without additional filtering, sorting, or result customization.
The query follows RediSearch query syntax, supporting:
"hello world" - searches for documents containing both terms"@title:redis" - searches within specific fields"redis AND search" or "redis | search""\"exact phrase\"" - searches for exact phrase matches"redi*" - prefix matching"@price:[100 200]" - numeric field filtering"@location:[lon lat radius unit]" - geo-spatial queriesTime complexity: O(N) where N is the number of results in the result set
index - the index name, as a keyquery - the query string following RediSearch query syntaxSearchReplySearchReply,
SearchArgs,
ftSearch(String, Object, SearchArgs)@Experimental RedisFuture<SearchReply<K,V>> ftSearch(String index, V query, SearchArgs<K,V> args)
This command performs a full-text search on the specified index with advanced configuration options provided through
SearchArgs. This variant allows fine-grained control over search behavior, result formatting, filtering, sorting,
and pagination.
The SearchArgs parameter enables you to specify:
Time complexity: O(N) where N is the number of results in the result set. Complexity varies based on query type, filters, and sorting requirements.
index - the index name, as a keyquery - the query string following RediSearch query syntaxargs - the search arguments containing advanced options and filtersSearchReplySearchReply,
SearchArgs,
ftSearch(String, Object)@Experimental RedisFuture<AggregationReply<K,V>> ftAggregate(String index, V query)
This command executes a search query and applies aggregation operations to transform and analyze the results. Unlike
ftSearch(String, Object), which returns individual documents, FT.AGGREGATE processes the result set through a
pipeline of transformations to produce analytical insights, summaries, and computed values.
This basic variant uses default aggregation behavior without additional pipeline operations. For advanced aggregations
with grouping, sorting, filtering, and custom transformations, use ftAggregate(String, Object, AggregateArgs).
Common use cases for aggregations include:
Time complexity: O(1) base complexity, but depends on the query and number of results processed
index - the index name, as a keyquery - the base filtering query that retrieves documents for aggregationSearchReplySearchReply,
AggregateArgs,
ftAggregate(String, Object, AggregateArgs)@Experimental RedisFuture<AggregationReply<K,V>> ftAggregate(String index, V query, AggregateArgs<K,V> args)
This command executes a search query and applies a sophisticated aggregation pipeline to transform, group, sort, and
analyze the results. The AggregateArgs parameter defines a series of operations that process the data
server-side, enabling powerful analytics and data transformation capabilities directly within Redis.
The aggregation pipeline supports the following operations:
Time complexity: Non-deterministic, depends on the query and aggregation operations performed. Generally linear to the number of results processed through the pipeline.
index - the index name, as a keyquery - the base filtering query that retrieves documents for aggregationargs - the aggregate arguments defining the processing pipeline and operationsSearchReplySearchReply,
AggregateArgs,
ftAggregate(String, Object),
#ftCursorread(String, Cursor)@Experimental RedisFuture<AggregationReply<K,V>> ftCursorread(String index, AggregationReply.Cursor cursor, int count)
This command is used to read the next batch of results from a cursor that was created by
ftAggregate(String, Object, AggregateArgs) with the WITHCURSOR option. Cursors provide an efficient way
to iterate through large result sets without loading all results into memory at once.
The count parameter overrides the COUNT value specified in the original FT.AGGREGATE command,
allowing you to control the batch size for this specific read operation.
Time complexity: O(1)
index - the index namecursor - the cursor obtained from a previous FT.AGGREGATE or FT.CURSOR READ commandcount - the number of results to read; overrides the COUNT from FT.AGGREGATEAggregationReplyAggregationReply,
ftAggregate(String, Object, AggregateArgs)@Experimental RedisFuture<AggregationReply<K,V>> ftCursorread(String index, AggregationReply.Cursor cursor)
This command is used to read the next batch of results from a cursor created by
ftAggregate(String, Object, AggregateArgs) with the WITHCURSOR option. This variant uses the default
batch size that was specified in the original FT.AGGREGATE command's WITHCURSOR clause.
Cursors provide an efficient way to iterate through large result sets without loading all results into memory at once.
When the cursor is exhausted (no more results), the returned SearchReply will have a cursor id of 0.
Time complexity: O(1)
index - the index namecursor - the cursor obtained from a previous FT.AGGREGATE or FT.CURSOR READ commandAggregationReplyAggregationReply,
ftAggregate(String, Object, AggregateArgs)@Experimental RedisFuture<String> ftCursordel(String index, AggregationReply.Cursor cursor)
This command is used to explicitly delete a cursor created by ftAggregate(String, Object, AggregateArgs) with
the WITHCURSOR option. Deleting a cursor frees up server resources and should be done when you no longer need to
read more results from the cursor.
Important: Cursors have a default timeout and may be automatically deleted by Redis if not accessed within the timeout period. However, it's good practice to explicitly delete cursors when you're finished with them to free up resources immediately.
Once a cursor is deleted, any subsequent attempts to read from it using #ftCursorread(String, Cursor) or
#ftCursorread(String, Cursor, int) will result in an error.
Time complexity: O(1)
index - the index name, as a keycursor - the cursor obtained from a previous FT.AGGREGATE or FT.CURSOR READ command"OK" if the cursor was successfully deletedftAggregate(String, Object, AggregateArgs),
#ftCursorread(String, Cursor),
#ftCursorread(String, Cursor, int)Copyright © 2025 lettuce.io. All rights reserved.