Skip to content

Commit

Permalink
Re-work FT.SEARCH (#3138)
Browse files Browse the repository at this point in the history
* Add FTSearchParams and SortingOrder

* Add FTAggregateParams (w/o GroupBy, Reduce)

* Remove FTAggregateParams

Jedis params pattern does not comply with FT.AGGREGATE arguments.

* format SearchWithParamsTest

* changes

* LazyRawable changes

* fixes

* fix test

* edit

* Payload related arguments are deprecated
  • Loading branch information
sazzad16 authored Sep 20, 2022
1 parent ff3f871 commit 9a69fb3
Show file tree
Hide file tree
Showing 19 changed files with 1,258 additions and 142 deletions.
10 changes: 10 additions & 0 deletions src/main/java/redis/clients/jedis/CommandObjects.java
Original file line number Diff line number Diff line change
Expand Up @@ -3089,6 +3089,16 @@ public CommandObject<String> ftAlter(String indexName, Iterable<SchemaField> sch
return new CommandObject<>(args, BuilderFactory.STRING);
}

public CommandObject<SearchResult> ftSearch(String indexName, String query) {
return new CommandObject<>(commandArguments(SearchCommand.SEARCH).add(indexName).add(query),
new SearchResultBuilder(true, false, false, true));
}

public CommandObject<SearchResult> ftSearch(String indexName, String query, FTSearchParams params) {
return new CommandObject<>(commandArguments(SearchCommand.SEARCH).add(indexName).add(query).addParams(params),
new SearchResultBuilder(!params.getNoContent(), params.getWithScores(), false, true));
}

public CommandObject<SearchResult> ftSearch(String indexName, Query query) {
return new CommandObject<>(commandArguments(SearchCommand.SEARCH).add(indexName).addParams(query),
new SearchResultBuilder(!query.getNoContent(), query.getWithScores(), query.getWithPayloads(), true));
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/redis/clients/jedis/MultiNodePipelineBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -3357,6 +3357,16 @@ public Response<String> ftAlter(String indexName, Iterable<SchemaField> schemaFi
return appendCommand(commandObjects.ftAlter(indexName, schemaFields));
}

@Override
public Response<SearchResult> ftSearch(String indexName, String query) {
return appendCommand(commandObjects.ftSearch(indexName, query));
}

@Override
public Response<SearchResult> ftSearch(String indexName, String query, FTSearchParams searchParams) {
return appendCommand(commandObjects.ftSearch(indexName, query, searchParams));
}

@Override
public Response<SearchResult> ftSearch(String indexName, Query query) {
return appendCommand(commandObjects.ftSearch(indexName, query));
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/redis/clients/jedis/Pipeline.java
Original file line number Diff line number Diff line change
Expand Up @@ -3336,6 +3336,16 @@ public Response<String> ftAlter(String indexName, Iterable<SchemaField> schemaFi
return appendCommand(commandObjects.ftAlter(indexName, schemaFields));
}

@Override
public Response<SearchResult> ftSearch(String indexName, String query) {
return appendCommand(commandObjects.ftSearch(indexName, query));
}

@Override
public Response<SearchResult> ftSearch(String indexName, String query, FTSearchParams searchParams) {
return appendCommand(commandObjects.ftSearch(indexName, query, searchParams));
}

@Override
public Response<SearchResult> ftSearch(String indexName, Query query) {
return appendCommand(commandObjects.ftSearch(indexName, query));
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/redis/clients/jedis/TransactionBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -3403,6 +3403,16 @@ public Response<String> ftAlter(String indexName, Iterable<SchemaField> schemaFi
return appendCommand(commandObjects.ftAlter(indexName, schemaFields));
}

@Override
public Response<SearchResult> ftSearch(String indexName, String query) {
return appendCommand(commandObjects.ftSearch(indexName, query));
}

@Override
public Response<SearchResult> ftSearch(String indexName, String query, FTSearchParams searchParams) {
return appendCommand(commandObjects.ftSearch(indexName, query, searchParams));
}

@Override
public Response<SearchResult> ftSearch(String indexName, Query query) {
return appendCommand(commandObjects.ftSearch(indexName, query));
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/redis/clients/jedis/UnifiedJedis.java
Original file line number Diff line number Diff line change
Expand Up @@ -3469,6 +3469,16 @@ public String ftAlter(String indexName, Iterable<SchemaField> schemaFields) {
return executeCommand(commandObjects.ftAlter(indexName, schemaFields));
}

@Override
public SearchResult ftSearch(String indexName, String query) {
return executeCommand(commandObjects.ftSearch(indexName, query));
}

@Override
public SearchResult ftSearch(String indexName, String query, FTSearchParams params) {
return executeCommand(commandObjects.ftSearch(indexName, query, params));
}

@Override
public SearchResult ftSearch(String indexName, Query query) {
return executeCommand(commandObjects.ftSearch(indexName, query));
Expand Down
14 changes: 0 additions & 14 deletions src/main/java/redis/clients/jedis/search/FTCreateParams.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public class FTCreateParams implements IParams {
private String languageField;
private Double score;
private String scoreField;
private byte[] payloadField;
private boolean maxTextFields;
private boolean noOffsets;
private Long temporary;
Expand Down Expand Up @@ -110,15 +109,6 @@ public FTCreateParams scoreField(String scoreField) {
return this;
}

/**
* Document attribute that you use as a binary safe payload string to the document that can be
* evaluated at query time by a custom scoring function or retrieved to the client.
*/
public FTCreateParams payloadField(byte[] payloadAttribute) {
this.payloadField = Arrays.copyOf(payloadAttribute, payloadAttribute.length);
return this;
}

/**
* Forces RediSearch to encode indexes as if there were more than 32 text attributes.
*/
Expand Down Expand Up @@ -230,10 +220,6 @@ public void addParams(CommandArguments args) {
args.add(SCORE_FIELD).add(scoreField);
}

if (payloadField != null) {
args.add(PAYLOAD_FIELD).add(payloadField);
}

if (maxTextFields) {
args.add(MAXTEXTFIELDS);
}
Expand Down
Loading

0 comments on commit 9a69fb3

Please sign in to comment.