K
- Key type.V
- Value type.public interface RediSearchAsyncCommands<K,V>
Modifier and Type | Method and Description |
---|---|
RedisFuture<AggregationReply<K,V>> |
ftAggregate(K index,
V query)
Run a search query on an index and perform basic aggregate transformations using default options.
|
RedisFuture<AggregationReply<K,V>> |
ftAggregate(K 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(K alias,
K index)
Add an alias to a search index.
|
RedisFuture<String> |
ftAliasdel(K alias)
Remove an alias from a search index.
|
RedisFuture<String> |
ftAliasupdate(K alias,
K index)
Update an existing alias to point to a different search index.
|
RedisFuture<String> |
ftAlter(K index,
boolean skipInitialScan,
List<FieldArgs<K>> fieldArgs)
Add new attributes to an existing search index.
|
RedisFuture<String> |
ftAlter(K index,
List<FieldArgs<K>> fieldArgs)
Add new attributes to an existing search index.
|
RedisFuture<String> |
ftCreate(K 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(K index,
List<FieldArgs<K>> fieldArgs)
Create a new search index with the given name and field definitions using default settings.
|
RedisFuture<String> |
ftCursordel(K index,
long cursorId)
Delete a cursor and free its associated resources.
|
RedisFuture<AggregationReply<K,V>> |
ftCursorread(K index,
long cursorId)
Read next results from an existing cursor using the default batch size.
|
RedisFuture<AggregationReply<K,V>> |
ftCursorread(K index,
long cursorId,
int count)
Read next results from an existing cursor.
|
RedisFuture<Long> |
ftDictadd(K dict,
V... terms)
Add terms to a dictionary.
|
RedisFuture<Long> |
ftDictdel(K dict,
V... terms)
Delete terms from a dictionary.
|
RedisFuture<List<V>> |
ftDictdump(K dict)
Dump all terms in a dictionary.
|
RedisFuture<String> |
ftDropindex(K index)
Drop a search index without deleting the associated documents.
|
RedisFuture<String> |
ftDropindex(K index,
boolean deleteDocuments)
Drop a search index with optional document deletion.
|
RedisFuture<String> |
ftExplain(K index,
V query)
Return the execution plan for a complex query.
|
RedisFuture<String> |
ftExplain(K 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(K index,
V query)
Search the index with a textual query using default search options.
|
RedisFuture<SearchReply<K,V>> |
ftSearch(K index,
V query,
SearchArgs<K,V> args)
Search the index with a textual query using advanced search options and filters.
|
RedisFuture<SpellCheckResult<V>> |
ftSpellcheck(K index,
V query)
Perform spelling correction on a query, returning suggestions for misspelled terms.
|
RedisFuture<SpellCheckResult<V>> |
ftSpellcheck(K 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(K index)
Dump synonym group contents.
|
RedisFuture<String> |
ftSynupdate(K index,
V synonymGroupId,
SynUpdateArgs<K,V> args,
V... terms)
Update a synonym group with additional terms and options.
|
RedisFuture<String> |
ftSynupdate(K index,
V synonymGroupId,
V... terms)
Update a synonym group with additional terms.
|
RedisFuture<List<V>> |
ftTagvals(K index,
K fieldName)
Return a distinct set of values indexed in a Tag field.
|
@Experimental RedisFuture<String> ftCreate(K 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 name, as a keyfieldArgs
- the FieldArgs
list defining the searchable fields and their types"OK"
if the index was created successfullyCreateArgs
,
FieldArgs
,
ftCreate(Object, CreateArgs, List)
,
ftDropindex(Object)
@Experimental RedisFuture<String> ftCreate(K 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 name, as a keyarguments
- 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(Object, List)
,
ftDropindex(Object)
@Experimental RedisFuture<String> ftAliasadd(K alias, K 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(Object, Object)
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(Object, Object)
,
ftAliasdel(Object)
@Experimental RedisFuture<String> ftAliasupdate(K alias, K index)
This command updates an existing alias to point to a different index, or creates the alias if it doesn't exist. Unlike
ftAliasadd(Object, Object)
, 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(Object, Object)
,
ftAliasdel(Object)
@Experimental RedisFuture<String> ftAliasdel(K 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(Object, Object)
to redirect before deletionTime complexity: O(1)
alias
- the alias name to remove"OK"
if the alias was successfully removedftAliasadd(Object, Object)
,
ftAliasupdate(Object, Object)
@Experimental RedisFuture<String> ftAlter(K 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(Object, List)
,
ftCreate(Object, CreateArgs, List)
@Experimental RedisFuture<String> ftAlter(K 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(Object, List)
,
ftCreate(Object, CreateArgs, List)
@Experimental RedisFuture<List<V>> ftTagvals(K index, K 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(Object, List)
,
ftCreate(Object, CreateArgs, List)
@Experimental RedisFuture<SpellCheckResult<V>> ftSpellcheck(K 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(Object, Object, SpellCheckArgs)
,
ftDictadd(Object, Object[])
,
ftDictdel(Object, Object[])
,
ftDictdump(Object)
@Experimental RedisFuture<SpellCheckResult<V>> ftSpellcheck(K 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(Object, Object)
,
ftDictadd(Object, Object[])
,
ftDictdel(Object, Object[])
,
ftDictdump(Object)
@Experimental RedisFuture<Long> ftDictadd(K 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(Object, Object[])
,
ftDictdump(Object)
@Experimental RedisFuture<Long> ftDictdel(K 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(Object, Object[])
,
ftDictdump(Object)
@Experimental RedisFuture<List<V>> ftDictdump(K 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(Object, Object[])
,
ftDictdel(Object, Object[])
@Experimental RedisFuture<String> ftExplain(K 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(Object, Object, ExplainArgs)
,
ftSearch(Object, Object)
@Experimental RedisFuture<String> ftExplain(K 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(Object, Object)
,
ftSearch(Object, 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(Object, CreateArgs, FieldArgs[])
,
ftDropindex(Object)
@Experimental RedisFuture<Map<V,List<V>>> ftSyndump(K 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(Object, Object, Object[])
,
ftSynupdate(Object, Object, SynUpdateArgs, Object[])
@Experimental RedisFuture<String> ftSynupdate(K 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(Object, Object, SynUpdateArgs, Object[])
,
ftSyndump(Object)
@Experimental RedisFuture<String> ftSynupdate(K 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(Object, Object, Object[])
,
ftSyndump(Object)
@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(K 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(Object, boolean)
,
ftCreate(Object, List)
@Experimental RedisFuture<String> ftDropindex(K 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(Object, 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(Object)
,
ftCreate(Object, List)
@Experimental RedisFuture<SearchReply<K,V>> ftSearch(K 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 syntaxSearchReply
SearchReply
,
SearchArgs
,
ftSearch(Object, Object, SearchArgs)
@Experimental RedisFuture<SearchReply<K,V>> ftSearch(K 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 filtersSearchReply
SearchReply
,
SearchArgs
,
ftSearch(Object, Object)
@Experimental RedisFuture<AggregationReply<K,V>> ftAggregate(K index, V query)
This command executes a search query and applies aggregation operations to transform and analyze the results. Unlike
ftSearch(Object, 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(Object, 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 aggregationSearchReply
SearchReply
,
AggregateArgs
,
ftAggregate(Object, Object, AggregateArgs)
@Experimental RedisFuture<AggregationReply<K,V>> ftAggregate(K 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 operationsSearchReply
SearchReply
,
AggregateArgs
,
ftAggregate(Object, Object)
,
ftCursorread(Object, long)
@Experimental RedisFuture<AggregationReply<K,V>> ftCursorread(K index, long cursorId, int count)
This command is used to read the next batch of results from a cursor created by
ftAggregate(Object, 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 name, as a keycursorId
- the cursor id obtained from a previous FT.AGGREGATE
or FT.CURSOR READ
commandcount
- the number of results to read. This parameter overrides the COUNT
specified in FT.AGGREGATE
SearchReply
SearchReply
,
ftAggregate(Object, Object, AggregateArgs)
@Experimental RedisFuture<AggregationReply<K,V>> ftCursorread(K index, long cursorId)
This command is used to read the next batch of results from a cursor created by
ftAggregate(Object, 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 name, as a keycursorId
- the cursor id obtained from a previous FT.AGGREGATE
or FT.CURSOR READ
commandSearchReply
SearchReply
,
ftAggregate(Object, Object, AggregateArgs)
@Experimental RedisFuture<String> ftCursordel(K index, long cursorId)
This command is used to explicitly delete a cursor created by ftAggregate(Object, 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 will 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(Object, long)
or
ftCursorread(Object, long, int)
will result in an error.
Time complexity: O(1)
index
- the index name, as a keycursorId
- the cursor id obtained from a previous FT.AGGREGATE
or FT.CURSOR READ
command"OK"
if the cursor was successfully deletedftAggregate(Object, Object, AggregateArgs)
,
ftCursorread(Object, long)
,
ftCursorread(Object, long, int)
Copyright © 2025 lettuce.io. All rights reserved.