diff --git a/java/client/src/main/java/glide/api/commands/servermodules/FT.java b/java/client/src/main/java/glide/api/commands/servermodules/FT.java index 7093eab121..6df06d47d7 100644 --- a/java/client/src/main/java/glide/api/commands/servermodules/FT.java +++ b/java/client/src/main/java/glide/api/commands/servermodules/FT.java @@ -707,7 +707,13 @@ public static CompletableFuture aliasupdate( * @return A string representing the execution plan. * @example *
{@code
-     * FT.explain(client, "myIndex", "*=>[KNN 2 @VEC $query_vec]").get();   // "Vector"
+     * FT.explain(client, "myIndex", "@price:[0 10]").get();   
+     * // the result can look like (the result is a string):
+     * //  Field {
+     * //    price
+     * //    0
+     * //    10
+     * // }
      * }
*/ public static CompletableFuture explain( @@ -727,7 +733,13 @@ public static CompletableFuture explain( * @return A string representing the execution plan. * @example *
{@code
-     * FT.explain(client, gs("myIndex"), gs("*=>[KNN 2 @VEC $query_vec]")).get();   // "Vector"
+     * FT.explain(client, "myIndex", "@price:[0 10]").get();   
+     * // the result can look like (the result is a string):
+     * //  Field {
+     * //    price
+     * //    0
+     * //    10
+     * // }     
      * }
*/ public static CompletableFuture explain( @@ -736,59 +748,6 @@ public static CompletableFuture explain( return executeCommand(client, args, false); } - /** - * Parse a query and return information about how that query was parsed. - * - * @param client The client to execute the command. - * @param indexName The index name to search into. - * @param query The text query to search. It is the same as the query passed as an argument to - * {@link FT#search(BaseClient, String, String)}. - * @param dialect The dialect version under which to execute the query. If not specified, the - * query executes under the default dialect version set during module initial loading. - * @return A string representing the execution plan. - * @example - *
{@code
-     * FT.explain(client, "myIndex", "*=>[KNN 2 @VEC $query_vec]", 12.2).get();   // "Vector"
-     * }
- */ - public static CompletableFuture explain( - @NonNull BaseClient client, - @NonNull String indexName, - @NonNull String query, - @NonNull Double dialect) { - var args = - concatenateArrays( - new GlideString[] {gs("FT.EXPLAIN"), gs(indexName), gs(query), gs(dialect.toString())}); - return executeCommand(client, args, false) - .thenApply(result -> ((GlideString) result).toString()); - } - - /** - * Parse a query and return information about how that query was parsed. - * - * @param client The client to execute the command. - * @param indexName The index name to search into. - * @param query The text query to search. It is the same as the query passed as an argument to - * {@link FT#search(BaseClient, String, String)}. - * @param dialect The dialect version under which to execute the query. If not specified, the - * query executes under the default dialect version set during module initial loading. - * @return A string representing the execution plan. - * @example - *
{@code
-     * FT.explain(client, gs("myIndex"), gs("*=>[KNN 2 @VEC $query_vec]"), 12.2).get();   // "Vector"
-     * }
- */ - public static CompletableFuture explain( - @NonNull BaseClient client, - @NonNull GlideString indexName, - @NonNull GlideString query, - @NonNull Double dialect) { - var args = - concatenateArrays( - new GlideString[] {gs("FT.EXPLAIN"), indexName, query, gs(dialect.toString())}); - return executeCommand(client, args, false); - } - /** * Same as the {@link FT#explain(BaseClient, String, String)} except that the results are * displayed in a different format. More useful with cli. @@ -800,7 +759,13 @@ public static CompletableFuture explain( * @return A string array representing the execution plan. * @example *
{@code
-     * FT.explaincli(client, "myIndex", "*=>[KNN 2 @VEC $query_vec]").get();   // "Vector"
+     * FT.explaincli(client, "myIndex",  "@price:[0 10]").get();   
+     * // the output can look like this (the result is an array)
+     * //  Field {
+     * //    price
+     * //    0
+     * //    10
+     * // } 
      * }
*/ public static CompletableFuture explaincli( @@ -821,7 +786,13 @@ public static CompletableFuture explaincli( * @return A string array representing the execution plan. * @example *
{@code
-     * FT.explaincli(client, gs("myIndex"), gs("*=>[KNN 2 @VEC $query_vec]")).get();   // "Vector"
+     * FT.explaincli(client, "myIndex",  "@price:[0 10]").get();   
+     * // the output can look like this (the result is an array)
+     * //  Field {
+     * //    price
+     * //    0
+     * //    10
+     * // } 
      * }
*/ public static CompletableFuture explaincli( @@ -836,66 +807,6 @@ public static CompletableFuture explaincli( return result; } - /** - * Same as the {@link FT#explain(BaseClient, String, String)} except that the results are - * displayed in a different format. More useful with cli. - * - * @param client The client to execute the command. - * @param indexName The index name to search into. - * @param query The text query to search. It is the same as the query passed as an argument to - * {@link FT#search(BaseClient, String, String)}. - * @param dialect The dialect version under which to execute the query. If not specified, the - * query executes under the default dialect version set during module initial loading. - * @return A string array representing the execution plan. - * @example - *
{@code
-     * FT.explaincli(client, "myIndex", "*=>[KNN 2 @VEC $query_vec]", 12.2).get();   // "Vector"
-     * }
- */ - public static CompletableFuture explaincli( - @NonNull BaseClient client, - @NonNull String indexName, - @NonNull String query, - @NonNull Double dialect) { - CompletableFuture result = explaincli(client, gs(indexName), gs(query), dialect); - return result.thenApply( - ret -> Arrays.stream(ret).map(e -> e.getString()).toArray(String[]::new)); - } - - /** - * Same as the {@link FT#explain(BaseClient, String, String)} except that the results are - * displayed in a different format. More useful with cli. - * - * @param client The client to execute the command. - * @param indexName The index name to search into. - * @param query The text query to search. It is the same as the query passed as an argument to - * {@link FT#search(BaseClient, String, String)}. - * @param dialect The dialect version under which to execute the query. If not specified, the - * query executes under the default dialect version set during module initial loading. - * @param options The additional parameter for the command - see {@link FTCreateOptions}. - * @return A string array representing the execution plan. - * @example - *
{@code
-     * FT.explaincli(client, gs("myIndex"), gs("*=>[KNN 2 @VEC $query_vec]"), 12.2).get();   // "Vector"
-     * }
- */ - public static CompletableFuture explaincli( - @NonNull BaseClient client, - @NonNull GlideString indexName, - @NonNull GlideString query, - @NonNull Double dialect) { - var args = - concatenateArrays( - new GlideString[] {gs("FT.EXPLAINCLI"), indexName, query, gs(dialect.toString())}); - CompletableFuture result = - ((GlideClusterClient) client) - .customCommand(args) - .thenApply(ClusterValue::getSingleValue) - .thenApply(ret -> (Object[]) ret) - .thenApply(ret -> castArray(ret, GlideString.class)); - return result; - } - /** * A wrapper for custom command API. * diff --git a/java/integTest/src/test/java/glide/modules/VectorSearchTests.java b/java/integTest/src/test/java/glide/modules/VectorSearchTests.java index 62962c9c4f..9f407c697b 100644 --- a/java/integTest/src/test/java/glide/modules/VectorSearchTests.java +++ b/java/integTest/src/test/java/glide/modules/VectorSearchTests.java @@ -852,12 +852,6 @@ public void ft_explain() { result = resultGS.toString(); assertTrue(result.contains("*")); - // with dialect option - result = FT.explain(client, indexName, query, 1.2).get(); - assertTrue(result.contains("price")); - assertTrue(result.contains("0")); - assertTrue(result.contains("10")); - assertEquals(OK, FT.dropindex(client, indexName).get()); // missing index throws an error. @@ -908,16 +902,6 @@ public void ft_explaincli() { } assertTrue((resultListGS).contains("*")); - // with dialect option - resultList.clear(); - result = FT.explaincli(client, indexName, query, 1.2).get(); - for (String r : result) { - resultList.add(r.trim()); // trim to remove any excess white space - } - assertTrue(resultList.contains("price")); - assertTrue(resultList.contains("0")); - assertTrue(resultList.contains("10")); - assertEquals(OK, FT.dropindex(client, indexName).get()); // missing index throws an error.