Package glide.api.commands.servermodules
Class FT
- java.lang.Object
-
- glide.api.commands.servermodules.FT
-
public class FT extends java.lang.ObjectModule for vector search commands.
-
-
Constructor Summary
Constructors Constructor Description FT()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Object>[]>aggregate(@NonNull BaseClient client, @NonNull GlideString indexName, @NonNull GlideString query)Runs a search query on an index, and perform aggregate transformations on the results.static java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Object>[]>aggregate(@NonNull BaseClient client, @NonNull GlideString indexName, @NonNull GlideString query, @NonNull FTAggregateOptions options)Runs a search query on an index, and perform aggregate transformations on the results.static java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Object>[]>aggregate(@NonNull BaseClient client, @NonNull java.lang.String indexName, @NonNull java.lang.String query)Runs a search query on an index, and perform aggregate transformations on the results.static java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Object>[]>aggregate(@NonNull BaseClient client, @NonNull java.lang.String indexName, @NonNull java.lang.String query, @NonNull FTAggregateOptions options)Runs a search query on an index, and perform aggregate transformations on the results.static java.util.concurrent.CompletableFuture<java.lang.String>aliasadd(@NonNull BaseClient client, @NonNull GlideString aliasName, @NonNull GlideString indexName)Adds an alias for an index.static java.util.concurrent.CompletableFuture<java.lang.String>aliasadd(@NonNull BaseClient client, @NonNull java.lang.String aliasName, @NonNull java.lang.String indexName)Adds an alias for an index.static java.util.concurrent.CompletableFuture<java.lang.String>aliasdel(@NonNull BaseClient client, @NonNull GlideString aliasName)Deletes an existing alias for an index.static java.util.concurrent.CompletableFuture<java.lang.String>aliasdel(@NonNull BaseClient client, @NonNull java.lang.String aliasName)Deletes an existing alias for an index.static java.util.concurrent.CompletableFuture<java.util.Map<GlideString,GlideString>>aliaslist(@NonNull BaseClient client)Lists all index aliases.static java.util.concurrent.CompletableFuture<java.lang.String>aliasupdate(@NonNull BaseClient client, @NonNull GlideString aliasName, @NonNull GlideString indexName)Update an existing alias to point to a different physical index.static java.util.concurrent.CompletableFuture<java.lang.String>aliasupdate(@NonNull BaseClient client, @NonNull java.lang.String aliasName, @NonNull java.lang.String indexName)Updates an existing alias to point to a different physical index.static java.util.concurrent.CompletableFuture<java.lang.String>create(@NonNull BaseClient client, @NonNull GlideString indexName, @NonNull FTCreateOptions.FieldInfo[] schema)Creates an index and initiates a backfill of that index.static java.util.concurrent.CompletableFuture<java.lang.String>create(@NonNull BaseClient client, @NonNull GlideString indexName, @NonNull FTCreateOptions.FieldInfo[] schema, @NonNull FTCreateOptions options)Creates an index and initiates a backfill of that index.static java.util.concurrent.CompletableFuture<java.lang.String>create(@NonNull BaseClient client, @NonNull java.lang.String indexName, @NonNull FTCreateOptions.FieldInfo[] schema)Creates an index and initiates a backfill of that index.static java.util.concurrent.CompletableFuture<java.lang.String>create(@NonNull BaseClient client, @NonNull java.lang.String indexName, @NonNull FTCreateOptions.FieldInfo[] schema, @NonNull FTCreateOptions options)Creates an index and initiates a backfill of that index.static java.util.concurrent.CompletableFuture<java.lang.String>dropindex(@NonNull BaseClient client, @NonNull GlideString indexName)Deletes an index and associated content.static java.util.concurrent.CompletableFuture<java.lang.String>dropindex(@NonNull BaseClient client, @NonNull java.lang.String indexName)Deletes an index and associated content.static java.util.concurrent.CompletableFuture<GlideString>explain(@NonNull BaseClient client, @NonNull GlideString indexName, @NonNull GlideString query)Parse a query and return information about how that query was parsed.static java.util.concurrent.CompletableFuture<java.lang.String>explain(@NonNull BaseClient client, @NonNull java.lang.String indexName, @NonNull java.lang.String query)Parse a query and return information about how that query was parsed.static java.util.concurrent.CompletableFuture<GlideString[]>explaincli(@NonNull BaseClient client, @NonNull GlideString indexName, @NonNull GlideString query)Same as theexplain(BaseClient, String, String)except that the results are displayed in a different format.static java.util.concurrent.CompletableFuture<java.lang.String[]>explaincli(@NonNull BaseClient client, @NonNull java.lang.String indexName, @NonNull java.lang.String query)Same as theexplain(BaseClient, String, String)except that the results are displayed in a different format.static java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Object>>info(@NonNull BaseClient client, @NonNull GlideString indexName)Returns information about a given index.static java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Object>>info(@NonNull BaseClient client, @NonNull GlideString indexName, @NonNull FTInfoOptions options)Returns information about a given index with additional options.static java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Object>>info(@NonNull BaseClient client, @NonNull java.lang.String indexName)Returns information about a given index.static java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Object>>info(@NonNull BaseClient client, @NonNull java.lang.String indexName, @NonNull FTInfoOptions options)Returns information about a given index with additional options.static java.util.concurrent.CompletableFuture<GlideString[]>list(@NonNull BaseClient client)Lists all indexes.static java.util.concurrent.CompletableFuture<java.lang.Object[]>profile(@NonNull BaseClient client, @NonNull GlideString indexName, @NonNull FTProfileOptions options)Runs a search or aggregation query and collects performance profiling information.static java.util.concurrent.CompletableFuture<java.lang.Object[]>profile(@NonNull BaseClient client, @NonNull java.lang.String indexName, @NonNull FTProfileOptions options)Runs a search or aggregation query and collects performance profiling information.static java.util.concurrent.CompletableFuture<java.lang.Object[]>search(@NonNull BaseClient client, @NonNull GlideString indexName, @NonNull GlideString query)Uses the provided query expression to locate keys within an index.static java.util.concurrent.CompletableFuture<java.lang.Object[]>search(@NonNull BaseClient client, @NonNull GlideString indexName, @NonNull GlideString query, @NonNull FTSearchOptions options)Uses the provided query expression to locate keys within an index.static java.util.concurrent.CompletableFuture<java.lang.Object[]>search(@NonNull BaseClient client, @NonNull java.lang.String indexName, @NonNull java.lang.String query)Uses the provided query expression to locate keys within an index.static java.util.concurrent.CompletableFuture<java.lang.Object[]>search(@NonNull BaseClient client, @NonNull java.lang.String indexName, @NonNull java.lang.String query, @NonNull FTSearchOptions options)Uses the provided query expression to locate keys within an index.
-
-
-
Method Detail
-
create
public static java.util.concurrent.CompletableFuture<java.lang.String> create(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String indexName, @NonNull @NonNull FTCreateOptions.FieldInfo[] schema)Creates an index and initiates a backfill of that index.- Parameters:
client- The client to execute the command.indexName- The index name.schema- Fields to populate into the index. Equivalent to `SCHEMA` block in the module API.- Returns:
"OK".- Example:
// Create an index for vectors of size 2: FT.create(client, "my_idx1", new FieldInfo[] { new FieldInfo("vec", VectorFieldFlat.builder(DistanceMetric.L2, 2).build()) }).get(); // Create a 6-dimensional JSON index using the HNSW algorithm: FT.create(client, "my_idx2", new FieldInfo[] { new FieldInfo("$.vec", "VEC", VectorFieldHnsw.builder(DistanceMetric.L2, 6).numberOfEdges(32).build()) }).get();
-
create
public static java.util.concurrent.CompletableFuture<java.lang.String> create(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String indexName, @NonNull @NonNull FTCreateOptions.FieldInfo[] schema, @NonNull @NonNull FTCreateOptions options)Creates an index and initiates a backfill of that index.- Parameters:
client- The client to execute the command.indexName- The index name.schema- Fields to populate into the index. Equivalent to `SCHEMA` block in the module API.options- Additional parameters for the command - seeFTCreateOptions.- Returns:
"OK".- Example:
// Create a 6-dimensional JSON index using the HNSW algorithm: FT.create(client, "json_idx1", new FieldInfo[] { new FieldInfo("$.vec", "VEC", VectorFieldHnsw.builder(DistanceMetric.L2, 6).numberOfEdges(32).build()) }, FTCreateOptions.builder().dataType(JSON).prefixes(new String[] {"json:"}).build(), ).get(); // Create a text search index with all 1.2 options: // TextField: noStem=true, weight=2.0, withSuffixTrie=true, noSuffixTrie=false, sortable=true // NumericField and TagField: sortable=true // Note: noStopWords and stopWords are mutually exclusive; withOffsets and noOffsets are // mutually exclusive; withSuffixTrie and noSuffixTrie are mutually exclusive. FT.create(client, "text_idx", new FieldInfo[] { new FieldInfo("title", new TextField(true, 2.0, true, false, true)), new FieldInfo("price", new NumericField(true)), new FieldInfo("category", new TagField(',', false, true)), }, FTCreateOptions.builder() .dataType(DataType.HASH) .prefixes(new String[] {"product:"}) .score(1.0) .language("english") .skipInitialScan(true) .minStemSize(4) .withOffsets(true) .stopWords(new String[] {"the", "a", "is"}) .punctuation(".,;!?") .build() ).get();
-
create
public static java.util.concurrent.CompletableFuture<java.lang.String> create(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString indexName, @NonNull @NonNull FTCreateOptions.FieldInfo[] schema)Creates an index and initiates a backfill of that index.- Parameters:
client- The client to execute the command.indexName- The index name.schema- Fields to populate into the index. Equivalent to `SCHEMA` block in the module API.- Returns:
"OK".- Example:
// Create an index for vectors of size 2: FT.create(client, gs("my_idx1"), new FieldInfo[] { new FieldInfo("vec", VectorFieldFlat.builder(DistanceMetric.L2, 2).build()) }).get(); // Create a 6-dimensional JSON index using the HNSW algorithm: FT.create(client, gs("my_idx2"), new FieldInfo[] { new FieldInfo(gs("$.vec"), gs("VEC"), VectorFieldHnsw.builder(DistanceMetric.L2, 6).numberOfEdges(32).build()) }).get();
-
create
public static java.util.concurrent.CompletableFuture<java.lang.String> create(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString indexName, @NonNull @NonNull FTCreateOptions.FieldInfo[] schema, @NonNull @NonNull FTCreateOptions options)Creates an index and initiates a backfill of that index.- Parameters:
client- The client to execute the command.indexName- The index name.schema- Fields to populate into the index. Equivalent to `SCHEMA` block in the module API.options- Additional parameters for the command - seeFTCreateOptions.- Returns:
OK.- Example:
// Create a 6-dimensional JSON index using the HNSW algorithm: FT.create(client, gs("json_idx1"), new FieldInfo[] { new FieldInfo(gs("$.vec"), gs("VEC"), VectorFieldHnsw.builder(DistanceMetric.L2, 6).numberOfEdges(32).build()) }, FTCreateOptions.builder().dataType(JSON).prefixes(new String[] {"json:"}).build(), ).get();
-
search
public static java.util.concurrent.CompletableFuture<java.lang.Object[]> search(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String indexName, @NonNull @NonNull java.lang.String query, @NonNull @NonNull FTSearchOptions options)Uses the provided query expression to locate keys within an index. Once located, the count and/or content of indexed fields within those keys can be returned.- Parameters:
client- The client to execute the command.indexName- The index name to search into.query- The text query to search.options- The search options - seeFTSearchOptions.- Returns:
- A two element array, where first element is count of documents in result set, and the
second element, which has format
Map<GlideString, Map<GlideString, GlideString>>- a mapping between document names and map of their attributes. WhenFTSearchOptions.FTSearchOptionsBuilder.nocontent()is set, the attribute maps will be empty.
IfFTSearchOptions.FTSearchOptionsBuilder.count()orFTSearchOptions.FTSearchOptionsBuilder.limit(int, int)with values0, 0is set, the command returns array with only one element - the count of the documents. - Example:
// Vector search example: byte[] vector = new byte[24]; Arrays.fill(vector, (byte) 0); var result = FT.search(client, "json_idx1", "*=>[KNN 2 @VEC $query_vec]", FTSearchOptions.builder().params(Map.of(gs("query_vec"), gs(vector))).build()) .get(); // Text search with all options: // Note: withSortKeys requires SORTBY; shardScope/consistency are cluster-mode options. var result = FT.search(client, "myIndex", "hello world", FTSearchOptions.builder() .verbatim() .inorder() .slop(1) .sortBy("price", FTSearchOptions.SortOrder.ASC) .withSortKeys() .shardScope(FTSearchOptions.ShardScope.ALLSHARDS) .consistency(FTSearchOptions.ConsistencyMode.CONSISTENT) .dialect(2) .build()) .get();
-
search
public static java.util.concurrent.CompletableFuture<java.lang.Object[]> search(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString indexName, @NonNull @NonNull GlideString query, @NonNull @NonNull FTSearchOptions options)Uses the provided query expression to locate keys within an index. Once located, the count and/or content of indexed fields within those keys can be returned.- Parameters:
client- The client to execute the command.indexName- The index name to search into.query- The text query to search.options- The search options - seeFTSearchOptions.- Returns:
- A two element array, where first element is count of documents in result set, and the
second element, which has format
Map<GlideString, Map<GlideString, GlideString>>- a mapping between document names and map of their attributes.
IfFTSearchOptions.FTSearchOptionsBuilder.count()orFTSearchOptions.FTSearchOptionsBuilder.limit(int, int)with values0, 0is set, the command returns array with only one element - the count of the documents. - Example:
byte[] vector = new byte[24]; Arrays.fill(vector, (byte) 0); var result = FT.search(client, gs("json_idx1"), gs("*=>[KNN 2 @VEC $query_vec]"), FTSearchOptions.builder().params(Map.of(gs("query_vec"), gs(vector))).build()) .get(); assertArrayEquals(result, new Object[] { 2L, Map.of( gs("json:2"), Map.of(gs("__VEC_score"), gs("11.1100006104"), gs("$"), gs("{\"vec\":[1.1,1.2,1.3,1.4,1.5,1.6]}")), gs("json:0"), Map.of(gs("__VEC_score"), gs("91"), gs("$"), gs("{\"vec\":[1,2,3,4,5,6]}"))) });
-
search
public static java.util.concurrent.CompletableFuture<java.lang.Object[]> search(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String indexName, @NonNull @NonNull java.lang.String query)Uses the provided query expression to locate keys within an index. Once located, the count and/or content of indexed fields within those keys can be returned.- Parameters:
client- The client to execute the command.indexName- The index name to search into.query- The text query to search.- Returns:
- A two element array, where first element is count of documents in result set, and the
second element, which has format
Map<GlideString, Map<GlideString, GlideString>>- a mapping between document names and map of their attributes. - Example:
byte[] vector = new byte[24]; Arrays.fill(vector, (byte) 0); var result = FT.search(client, "json_idx1", "*").get(); assertArrayEquals(result, new Object[] { 2L, Map.of( gs("json:2"), Map.of(gs("$"), gs("{\"vec\":[1.1,1.2,1.3,1.4,1.5,1.6]}")), gs("json:0"), Map.of(gs("$"), gs("{\"vec\":[1,2,3,4,5,6]}"))) });
-
search
public static java.util.concurrent.CompletableFuture<java.lang.Object[]> search(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString indexName, @NonNull @NonNull GlideString query)Uses the provided query expression to locate keys within an index. Once located, the count and/or content of indexed fields within those keys can be returned.- Parameters:
client- The client to execute the command.indexName- The index name to search into.query- The text query to search.- Returns:
- A two element array, where first element is count of documents in result set, and the
second element, which has format
Map<GlideString, Map<GlideString, GlideString>>- a mapping between document names and map of their attributes. - Example:
byte[] vector = new byte[24]; Arrays.fill(vector, (byte) 0); var result = FT.search(client, gs("json_idx1"), gs("*")).get(); assertArrayEquals(result, new Object[] { 2L, Map.of( gs("json:2"), Map.of(gs("$"), gs("{\"vec\":[1.1,1.2,1.3,1.4,1.5,1.6]}")), gs("json:0"), Map.of(gs("$"), gs("{\"vec\":[1,2,3,4,5,6]}"))) });
-
dropindex
public static java.util.concurrent.CompletableFuture<java.lang.String> dropindex(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String indexName)Deletes an index and associated content. Indexed document keys are unaffected.- Parameters:
client- The client to execute the command.indexName- The index name.- Returns:
"OK".- Example:
FT.dropindex(client, "hash_idx1").get();
-
dropindex
public static java.util.concurrent.CompletableFuture<java.lang.String> dropindex(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString indexName)Deletes an index and associated content. Indexed document keys are unaffected.- Parameters:
client- The client to execute the command.indexName- The index name.- Returns:
"OK".- Example:
FT.dropindex(client, gs("hash_idx1")).get();
-
aggregate
public static java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Object>[]> aggregate(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String indexName, @NonNull @NonNull java.lang.String query)
Runs a search query on an index, and perform aggregate transformations on the results.- Parameters:
client- The client to execute the command.indexName- The index name.query- The text query to search.- Returns:
- Results of the last stage of the pipeline.
- Example:
// example of using the API: FT.aggregate(client, "myIndex", "*").get(); // the response contains data in the following format: Map<GlideString, Object>[] response = new Map[] { Map.of( gs("condition"), gs("refurbished"), gs("bicycles"), new Object[] { gs("bicycle:9") } ), Map.of( gs("condition"), gs("used"), gs("bicycles"), new Object[] { gs("bicycle:1"), gs("bicycle:2"), gs("bicycle:3") } ), Map.of( gs("condition"), gs("new"), gs("bicycles"), new Object[] { gs("bicycle:0"), gs("bicycle:5") } ) };
-
aggregate
public static java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Object>[]> aggregate(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String indexName, @NonNull @NonNull java.lang.String query, @NonNull @NonNull FTAggregateOptions options)
Runs a search query on an index, and perform aggregate transformations on the results.- Parameters:
client- The client to execute the command.indexName- The index name.query- The text query to search.options- Additional parameters for the command - seeFTAggregateOptions.- Returns:
- Results of the last stage of the pipeline.
- Example:
// example of using the API: FTAggregateOptions options = FTAggregateOptions.builder() .loadFields(new String[] {"__key"}) .addClause( new FTAggregateOptions.GroupBy( new String[] {"@condition"}, new Reducer[] { new Reducer("TOLIST", new String[] {"__key"}, "bicycles") })) .build(); FT.aggregate(client, "myIndex", "*", options).get(); // the response contains data in the following format: Map<GlideString, Object>[] response = new Map[] { Map.of( gs("condition"), gs("refurbished"), gs("bicycles"), new Object[] { gs("bicycle:9") } ), Map.of( gs("condition"), gs("used"), gs("bicycles"), new Object[] { gs("bicycle:1"), gs("bicycle:2"), gs("bicycle:3") } ), Map.of( gs("condition"), gs("new"), gs("bicycles"), new Object[] { gs("bicycle:0"), gs("bicycle:5") } ) }; // Aggregate with all query flags: FTAggregateOptions opts12 = FTAggregateOptions.builder() .loadAll() .verbatim() .inorder() .slop(1) .dialect(2) .build(); FT.aggregate(client, "myIndex", "@score:[20 +inf]", opts12).get();
-
aggregate
public static java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Object>[]> aggregate(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString indexName, @NonNull @NonNull GlideString query)
Runs a search query on an index, and perform aggregate transformations on the results.- Parameters:
client- The client to execute the command.indexName- The index name.query- The text query to search.- Returns:
- Results of the last stage of the pipeline.
- Example:
// example of using the API: FT.aggregate(client, gs("myIndex"), gs("*")).get(); // the response contains data in the following format: Map<GlideString, Object>[] response = new Map[] { Map.of( gs("condition"), gs("refurbished"), gs("bicycles"), new Object[] { gs("bicycle:9") } ), Map.of( gs("condition"), gs("used"), gs("bicycles"), new Object[] { gs("bicycle:1"), gs("bicycle:2"), gs("bicycle:3") } ), Map.of( gs("condition"), gs("new"), gs("bicycles"), new Object[] { gs("bicycle:0"), gs("bicycle:5") } ) };
-
aggregate
public static java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Object>[]> aggregate(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString indexName, @NonNull @NonNull GlideString query, @NonNull @NonNull FTAggregateOptions options)
Runs a search query on an index, and perform aggregate transformations on the results.- Parameters:
client- The client to execute the command.indexName- The index name.query- The text query to search.options- Additional parameters for the command - seeFTAggregateOptions.- Returns:
- Results of the last stage of the pipeline.
- Example:
// example of using the API: FTAggregateOptions options = FTAggregateOptions.builder() .loadFields(new String[] {"__key"}) .addClause( new FTAggregateOptions.GroupBy( new String[] {"@condition"}, new Reducer[] { new Reducer("TOLIST", new String[] {"__key"}, "bicycles") })) .build(); FT.aggregate(client, gs("myIndex"), gs("*"), options).get(); // the response contains data in the following format: Map<GlideString, Object>[] response = new Map[] { Map.of( gs("condition"), gs("refurbished"), gs("bicycles"), new Object[] { gs("bicycle:9") } ), Map.of( gs("condition"), gs("used"), gs("bicycles"), new Object[] { gs("bicycle:1"), gs("bicycle:2"), gs("bicycle:3") } ), Map.of( gs("condition"), gs("new"), gs("bicycles"), new Object[] { gs("bicycle:0"), gs("bicycle:5") } ) };
-
profile
public static java.util.concurrent.CompletableFuture<java.lang.Object[]> profile(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String indexName, @NonNull @NonNull FTProfileOptions options)Runs a search or aggregation query and collects performance profiling information.- Parameters:
client- The client to execute the command.indexName- The index name.options- Querying and profiling parameters - seeFTProfileOptions.- Returns:
- A two-element array. The first element contains results of query being profiled, the second element stores profiling information.
- Example:
var options = FTSearchOptions.builder().params(Map.of( gs("query_vec"), gs(new byte[] { (byte) 0, (byte) 0, (byte) 0, (byte) 0 }))) .build(); var result = FT.profile(client, "myIndex", new FTProfileOptions("*=>[KNN 2 @VEC $query_vec]", options)).get(); // result[0] contains `FT.SEARCH` response with the given options and query // result[1] contains profiling data as a `Map<GlideString, Long>`
-
profile
public static java.util.concurrent.CompletableFuture<java.lang.Object[]> profile(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString indexName, @NonNull @NonNull FTProfileOptions options)Runs a search or aggregation query and collects performance profiling information.- Parameters:
client- The client to execute the command.indexName- The index name.options- Querying and profiling parameters - seeFTProfileOptions.- Returns:
- A two-element array. The first element contains results of query being profiled, the second element stores profiling information.
- Example:
var commandLine = new String[] { "*", "LOAD", "1", "__key", "GROUPBY", "1", "@condition", "REDUCE", "COUNT", "0", "AS", "bicylces" }; var result = FT.profile(client, gs("myIndex"), new FTProfileOptions(QueryType.AGGREGATE, commandLine)).get(); // result[0] contains `FT.AGGREGATE` response with the given command line // result[1] contains profiling data as a `Map<GlideString, Long>`
-
info
public static java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Object>> info(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String indexName)Returns information about a given index.- Parameters:
client- The client to execute the command.indexName- The index name.- Returns:
- Nested maps with info about the index. See example for more details.
- Example:
// example of using the API: Map<String, Object> response = FT.info(client, "myIndex").get(); // the response contains data in the following format: Map<String, Object> data = Map.of( "index_name", gs("myIndex"), "index_status", gs("AVAILABLE"), "key_type", gs("JSON"), "creation_timestamp", 1728348101728771L, "key_prefixes", new Object[] { gs("json:") }, "num_indexed_vectors", 0L, "space_usage", 653471L, "num_docs", 0L, "vector_space_usage", 653471L, "index_degradation_percentage", 0L, "fulltext_space_usage", 0L, "current_lag", 0L, "fields", new Object [] { Map.of( gs("identifier"), gs("$.vec"), gs("type"), gs("VECTOR"), gs("field_name"), gs("VEC"), gs("option"), gs(""), gs("vector_params", Map.of( gs("data_type", gs("FLOAT32"), gs("initial_capacity", 1000L, gs("current_capacity", 1000L, gs("distance_metric", gs("L2"), gs("dimension", 6L, gs("block_size", 1024L, gs("algorithm", gs("FLAT") ) ), Map.of( gs("identifier"), gs("name"), gs("type"), gs("TEXT"), gs("field_name"), gs("name"), gs("option"), gs("") ), } );
-
info
public static java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Object>> info(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString indexName)Returns information about a given index.- Parameters:
client- The client to execute the command.indexName- The index name.- Returns:
- Nested maps with info about the index. See example for more details.
- Example:
// example of using the API: Map<String, Object> response = FT.info(client, gs("myIndex")).get(); // the response contains data in the following format: Map<String, Object> data = Map.of( "index_name", gs("myIndex"), "index_status", gs("AVAILABLE"), "key_type", gs("JSON"), "creation_timestamp", 1728348101728771L, "key_prefixes", new Object[] { gs("json:") }, "num_indexed_vectors", 0L, "space_usage", 653471L, "num_docs", 0L, "vector_space_usage", 653471L, "index_degradation_percentage", 0L, "fulltext_space_usage", 0L, "current_lag", 0L, "fields", new Object [] { Map.of( gs("identifier"), gs("$.vec"), gs("type"), gs("VECTOR"), gs("field_name"), gs("VEC"), gs("option"), gs(""), gs("vector_params", Map.of( gs("data_type", gs("FLOAT32"), gs("initial_capacity", 1000L, gs("current_capacity", 1000L, gs("distance_metric", gs("L2"), gs("dimension", 6L, gs("block_size", 1024L, gs("algorithm", gs("FLAT") ) ), Map.of( gs("identifier"), gs("name"), gs("type"), gs("TEXT"), gs("field_name"), gs("name"), gs("option"), gs("") ), } );
-
info
public static java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Object>> info(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String indexName, @NonNull @NonNull FTInfoOptions options)Returns information about a given index with additional options.- Parameters:
client- The client to execute the command.indexName- The index name.options- Additional parameters for the command - seeFTInfoOptions.- Returns:
- Nested maps with info about the index.
- Example:
// Get local index info: Map<String, Object> info = FT.info(client, "myIndex", new FTInfoOptions(FTInfoOptions.InfoScope.LOCAL)).get(); // Get cluster-wide info (requires coordinator): Map<String, Object> clusterInfo = FT.info(client, "myIndex", new FTInfoOptions(FTInfoOptions.InfoScope.PRIMARY, FTInfoOptions.ShardScope.ALLSHARDS, FTInfoOptions.ConsistencyMode.CONSISTENT)).get();
-
info
public static java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Object>> info(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString indexName, @NonNull @NonNull FTInfoOptions options)Returns information about a given index with additional options.- Parameters:
client- The client to execute the command.indexName- The index name.options- Additional parameters for the command - seeFTInfoOptions.- Returns:
- Nested maps with info about the index.
-
list
public static java.util.concurrent.CompletableFuture<GlideString[]> list(@NonNull @NonNull BaseClient client)
Lists all indexes.- Parameters:
client- The client to execute the command.- Returns:
- An array of index names.
- Example:
GlideString[] indices = FT.list(client).get();
-
aliasadd
public static java.util.concurrent.CompletableFuture<java.lang.String> aliasadd(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String aliasName, @NonNull @NonNull java.lang.String indexName)Adds an alias for an index. The new alias name can be used anywhere that an index name is required.- Parameters:
client- The client to execute the command.aliasName- The alias to be added to an index.indexName- The index name for which the alias has to be added.- Returns:
"OK".- Example:
FT.aliasadd(client, "myalias", "myindex").get(); // "OK"
-
aliasadd
public static java.util.concurrent.CompletableFuture<java.lang.String> aliasadd(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString aliasName, @NonNull @NonNull GlideString indexName)Adds an alias for an index. The new alias name can be used anywhere that an index name is required.- Parameters:
client- The client to execute the command.aliasName- The alias to be added to an index.indexName- The index name for which the alias has to be added.- Returns:
"OK".- Example:
FT.aliasadd(client, gs("myalias"), gs("myindex")).get(); // "OK"
-
aliasdel
public static java.util.concurrent.CompletableFuture<java.lang.String> aliasdel(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String aliasName)Deletes an existing alias for an index.- Parameters:
client- The client to execute the command.aliasName- The existing alias to be deleted for an index.- Returns:
"OK".- Example:
FT.aliasdel(client, "myalias").get(); // "OK"
-
aliasdel
public static java.util.concurrent.CompletableFuture<java.lang.String> aliasdel(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString aliasName)Deletes an existing alias for an index.- Parameters:
client- The client to execute the command.aliasName- The existing alias to be deleted for an index.- Returns:
"OK".- Example:
FT.aliasdel(client, gs("myalias")).get(); // "OK"
-
aliasupdate
public static java.util.concurrent.CompletableFuture<java.lang.String> aliasupdate(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String aliasName, @NonNull @NonNull java.lang.String indexName)Updates an existing alias to point to a different physical index. This command only affects future references to the alias.- Parameters:
client- The client to execute the command.aliasName- The alias name. This alias will now be pointed to a different index.indexName- The index name for which an existing alias has to be updated.- Returns:
"OK".- Example:
FT.aliasupdate(client, "myalias", "myindex").get(); // "OK"
-
aliasupdate
public static java.util.concurrent.CompletableFuture<java.lang.String> aliasupdate(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString aliasName, @NonNull @NonNull GlideString indexName)Update an existing alias to point to a different physical index. This command only affects future references to the alias.- Parameters:
client- The client to execute the command.aliasName- The alias name. This alias will now be pointed to a different index.indexName- The index name for which an existing alias has to be updated.- Returns:
"OK".- Example:
FT.aliasupdate(client, gs("myalias"), gs("myindex")).get(); // "OK"
-
aliaslist
public static java.util.concurrent.CompletableFuture<java.util.Map<GlideString,GlideString>> aliaslist(@NonNull @NonNull BaseClient client)
Lists all index aliases.- Parameters:
client- The client to execute the command.- Returns:
- A map of index aliases to indices being aliased.
- Example:
var aliases = FT.aliaslist(client).get(); // the response contains data in the following format: Map<GlideString, GlideString> aliases = Map.of( gs("alias"), gs("myIndex"), );
-
explain
public static java.util.concurrent.CompletableFuture<java.lang.String> explain(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String indexName, @NonNull @NonNull java.lang.String query)Parse a query and return information about how that query was parsed.- Parameters:
client- The client to execute the command.indexName- The index name to search into.query- The text query to search. It is the same as the query passed as an argument tosearch(BaseClient, String, String)andaggregate(BaseClient, String, String).- Returns:
- A
Stringrepresenting the execution plan. - Example:
String result = FT.explain(client, "myIndex", "@price:[0 10]").get(); assert result.equals("Field {\n\tprice\n\t0\n\t10\n}");
-
explain
public static java.util.concurrent.CompletableFuture<GlideString> explain(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString indexName, @NonNull @NonNull GlideString query)
Parse a query and return information about how that query was parsed.- Parameters:
client- The client to execute the command.indexName- The index name to search into.query- The text query to search. It is the same as the query passed as an argument tosearch(BaseClient, GlideString, GlideString)andaggregate(BaseClient, GlideString, GlideString).- Returns:
- A
GlideStringrepresenting the execution plan. - Example:
GlideString result = FT.explain(client, gs("myIndex"), gs("@price:[0 10]")).get(); assert result.equals("Field {\n\tprice\n\t0\n\t10\n}");
-
explaincli
public static java.util.concurrent.CompletableFuture<java.lang.String[]> explaincli(@NonNull @NonNull BaseClient client, @NonNull @NonNull java.lang.String indexName, @NonNull @NonNull java.lang.String query)Same as theexplain(BaseClient, String, String)except that the results are displayed in a different format.- Parameters:
client- The client to execute the command.indexName- The index name to search into.query- The text query to search. It is the same as the query passed as an argument tosearch(BaseClient, String, String)andaggregate(BaseClient, String, String).- Returns:
- A
String[]representing the execution plan. - Example:
String[] result = FT.explaincli(client, "myIndex", "@price:[0 10]").get(); assert Arrays.equals(result, new String[]{ "Field {", " price", " 0", " 10", "}" });
-
explaincli
public static java.util.concurrent.CompletableFuture<GlideString[]> explaincli(@NonNull @NonNull BaseClient client, @NonNull @NonNull GlideString indexName, @NonNull @NonNull GlideString query)
Same as theexplain(BaseClient, String, String)except that the results are displayed in a different format.- Parameters:
client- The client to execute the command.indexName- The index name to search into.query- The text query to search. It is the same as the query passed as an argument tosearch(BaseClient, GlideString, GlideString)andaggregate(BaseClient, GlideString, GlideString).- Returns:
- A
GlideString[]representing the execution plan. - Example:
GlideString[] result = FT.explaincli(client, gs("myIndex"), gs("@price:[0 10]")).get(); assert Arrays.equals(result, new GlideString[]{ gs("Field {"), gs(" price"), gs(" 0"), gs(" 10"), gs("}") });
-
-