Skip to content

Commit ab76b4b

Browse files
committed
FT.SEARCH added
Vibe code the FT.SEARCH command Pulled latest from the integration branch Fixed a lot of the hallucinations RESP2 parser improvements JSON Indexing tests Add some advanced use-cases Fixed all integration tests Fixed schema fields, added vector tests, but they are all failing Fixed vector search tests Improve coverage of integration and unit tests One unit test fails
1 parent 8d9f33c commit ab76b4b

File tree

57 files changed

+8540
-729
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+8540
-729
lines changed

src/main/java/io/lettuce/core/AbstractRedisAsyncCommands.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,10 @@
4848
import io.lettuce.core.protocol.CommandType;
4949
import io.lettuce.core.protocol.ProtocolKeyword;
5050
import io.lettuce.core.protocol.RedisCommand;
51-
import io.lettuce.core.search.Field;
51+
import io.lettuce.core.search.SearchResults;
5252
import io.lettuce.core.search.arguments.CreateArgs;
53+
import io.lettuce.core.search.arguments.FieldArgs;
54+
import io.lettuce.core.search.arguments.SearchArgs;
5355
import io.lettuce.core.vector.RawVector;
5456
import io.lettuce.core.vector.VectorMetadata;
5557

@@ -1526,15 +1528,20 @@ public boolean isOpen() {
15261528
}
15271529

15281530
@Override
1529-
public RedisFuture<String> ftCreate(K index, CreateArgs<K, V> options, List<Field<K>> fields) {
1530-
return dispatch(searchCommandBuilder.ftCreate(index, options, fields));
1531+
public RedisFuture<String> ftCreate(K index, CreateArgs<K, V> options, List<FieldArgs<K>> fieldArgs) {
1532+
return dispatch(searchCommandBuilder.ftCreate(index, options, fieldArgs));
15311533
}
15321534

15331535
@Override
15341536
public RedisFuture<String> ftDropindex(K index, boolean deleteDocumentKeys) {
15351537
return dispatch(searchCommandBuilder.ftDropindex(index, deleteDocumentKeys));
15361538
}
15371539

1540+
@Override
1541+
public RedisFuture<SearchResults<K, V>> ftSearch(K index, V query, SearchArgs<K, V> args) {
1542+
return dispatch(searchCommandBuilder.ftSearch(index, query, args));
1543+
}
1544+
15381545
@Override
15391546
public RedisFuture<List<Long>> jsonArrappend(K key, JsonPath jsonPath, JsonValue... values) {
15401547
return dispatch(jsonCommandBuilder.jsonArrappend(key, jsonPath, values));

src/main/java/io/lettuce/core/AbstractRedisReactiveCommands.java

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@
4949
import io.lettuce.core.protocol.RedisCommand;
5050
import io.lettuce.core.protocol.TracedCommand;
5151
import io.lettuce.core.resource.ClientResources;
52-
import io.lettuce.core.search.Field;
52+
import io.lettuce.core.search.SearchResults;
5353
import io.lettuce.core.search.arguments.CreateArgs;
54+
import io.lettuce.core.search.arguments.FieldArgs;
55+
import io.lettuce.core.search.arguments.SearchArgs;
5456
import io.lettuce.core.tracing.TraceContext;
5557
import io.lettuce.core.tracing.TraceContextProvider;
5658
import io.lettuce.core.tracing.Tracing;
@@ -88,13 +90,13 @@
8890
* @author Tihomir Mateev
8991
* @since 4.0
9092
*/
91-
public abstract class AbstractRedisReactiveCommands<K, V> implements RedisAclReactiveCommands<K, V>,
92-
RedisHashReactiveCommands<K, V>, RedisKeyReactiveCommands<K, V>, RedisStringReactiveCommands<K, V>,
93-
RedisListReactiveCommands<K, V>, RedisSetReactiveCommands<K, V>, RedisSortedSetReactiveCommands<K, V>,
94-
RedisScriptingReactiveCommands<K, V>, RedisServerReactiveCommands<K, V>, RedisHLLReactiveCommands<K, V>,
95-
BaseRedisReactiveCommands<K, V>, RedisTransactionalReactiveCommands<K, V>, RedisGeoReactiveCommands<K, V>,
96-
RedisClusterReactiveCommands<K, V>, RedisJsonReactiveCommands<K, V>, RedisVectorSetReactiveCommands<K, V>,
97-
RediSearchReactiveCommands<K, V>{
93+
public abstract class AbstractRedisReactiveCommands<K, V>
94+
implements RedisAclReactiveCommands<K, V>, RedisHashReactiveCommands<K, V>, RedisKeyReactiveCommands<K, V>,
95+
RedisStringReactiveCommands<K, V>, RedisListReactiveCommands<K, V>, RedisSetReactiveCommands<K, V>,
96+
RedisSortedSetReactiveCommands<K, V>, RedisScriptingReactiveCommands<K, V>, RedisServerReactiveCommands<K, V>,
97+
RedisHLLReactiveCommands<K, V>, BaseRedisReactiveCommands<K, V>, RedisTransactionalReactiveCommands<K, V>,
98+
RedisGeoReactiveCommands<K, V>, RedisClusterReactiveCommands<K, V>, RedisJsonReactiveCommands<K, V>,
99+
RedisVectorSetReactiveCommands<K, V>, RediSearchReactiveCommands<K, V> {
98100

99101
private final StatefulConnection<K, V> connection;
100102

@@ -1591,15 +1593,20 @@ public boolean isOpen() {
15911593
}
15921594

15931595
@Override
1594-
public Mono<String> ftCreate(K index, CreateArgs<K, V> options, List<Field<K>> fields) {
1595-
return createMono(() -> searchCommandBuilder.ftCreate(index, options, fields));
1596+
public Mono<String> ftCreate(K index, CreateArgs<K, V> options, List<FieldArgs<K>> fieldArgs) {
1597+
return createMono(() -> searchCommandBuilder.ftCreate(index, options, fieldArgs));
15961598
}
15971599

15981600
@Override
15991601
public Mono<String> ftDropindex(K index, boolean deleteDocumentKeys) {
16001602
return createMono(() -> searchCommandBuilder.ftDropindex(index, deleteDocumentKeys));
16011603
}
16021604

1605+
@Override
1606+
public Mono<SearchResults<K, V>> ftSearch(K index, V query, SearchArgs<K, V> args) {
1607+
return createMono(() -> searchCommandBuilder.ftSearch(index, query, args));
1608+
}
1609+
16031610
@Override
16041611
public Flux<Long> jsonArrappend(K key, JsonPath jsonPath, JsonValue... values) {
16051612
return createDissolvingFlux(() -> jsonCommandBuilder.jsonArrappend(key, jsonPath, values));

src/main/java/io/lettuce/core/RediSearchCommandBuilder.java

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@
77
package io.lettuce.core;
88

99
import io.lettuce.core.codec.RedisCodec;
10+
import io.lettuce.core.output.EncodedComplexOutput;
1011
import io.lettuce.core.output.StatusOutput;
1112
import io.lettuce.core.protocol.BaseRedisCommandBuilder;
1213
import io.lettuce.core.protocol.Command;
1314
import io.lettuce.core.protocol.CommandArgs;
1415
import io.lettuce.core.protocol.CommandKeyword;
15-
import io.lettuce.core.protocol.RedisCommand;
16+
import io.lettuce.core.search.SearchResults;
17+
import io.lettuce.core.search.SearchResultsParser;
1618
import io.lettuce.core.search.arguments.CreateArgs;
17-
import io.lettuce.core.search.Field;
19+
import io.lettuce.core.search.arguments.FieldArgs;
20+
import io.lettuce.core.search.arguments.SearchArgs;
1821

1922
import java.util.List;
2023

@@ -25,7 +28,7 @@
2528
*
2629
* @param <K> Key type.
2730
* @param <V> Value type.
28-
* @since 6.6
31+
* @since 6.8
2932
*/
3033
class RediSearchCommandBuilder<K, V> extends BaseRedisCommandBuilder<K, V> {
3134

@@ -34,16 +37,16 @@ class RediSearchCommandBuilder<K, V> extends BaseRedisCommandBuilder<K, V> {
3437
}
3538

3639
/**
37-
* Create a new index with the given name, index options and fields.
40+
* Create a new index with the given name, index options and fieldArgs.
3841
*
3942
* @param index the index name
4043
* @param createArgs the index options
41-
* @param fields the fields
44+
* @param fieldArgs the fieldArgs
4245
* @return the result of the create command
4346
*/
44-
public Command<K, V, String> ftCreate(K index, CreateArgs<K, V> createArgs, List<Field<K>> fields) {
47+
public Command<K, V, String> ftCreate(K index, CreateArgs<K, V> createArgs, List<FieldArgs<K>> fieldArgs) {
4548
notNullKey(index);
46-
notEmpty(fields.toArray());
49+
notEmpty(fieldArgs.toArray());
4750

4851
CommandArgs<K, V> args = new CommandArgs<>(codec).addKey(index);
4952

@@ -53,14 +56,36 @@ public Command<K, V, String> ftCreate(K index, CreateArgs<K, V> createArgs, List
5356

5457
args.add(CommandKeyword.SCHEMA);
5558

56-
for (Field<K> field : fields) {
57-
field.build(args);
59+
for (FieldArgs<K> arg : fieldArgs) {
60+
arg.build(args);
5861
}
5962

6063
return createCommand(FT_CREATE, new StatusOutput<>(codec), args);
6164

6265
}
6366

67+
/**
68+
* Search the index with the given name using the specified query and search arguments.
69+
*
70+
* @param index the index name
71+
* @param query the query
72+
* @param searchArgs the search arguments
73+
* @return the result of the search command
74+
*/
75+
public Command<K, V, SearchResults<K, V>> ftSearch(K index, V query, SearchArgs<K, V> searchArgs) {
76+
notNullKey(index);
77+
notNullKey(query);
78+
79+
CommandArgs<K, V> args = new CommandArgs<>(codec).addKey(index);
80+
args.addValue(query);
81+
82+
if (searchArgs != null) {
83+
searchArgs.build(args);
84+
}
85+
86+
return createCommand(FT_SEARCH, new EncodedComplexOutput<>(codec, new SearchResultsParser<>(codec, searchArgs)), args);
87+
}
88+
6489
/**
6590
* Drop the index with the given name.
6691
*

src/main/java/io/lettuce/core/api/async/RediSearchAsyncCommands.java

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88

99
import java.util.List;
1010
import io.lettuce.core.RedisFuture;
11-
import io.lettuce.core.search.Field;
11+
import io.lettuce.core.search.SearchResults;
1212
import io.lettuce.core.search.arguments.CreateArgs;
13+
import io.lettuce.core.search.arguments.FieldArgs;
14+
import io.lettuce.core.search.arguments.SearchArgs;
1315

1416
/**
1517
* Asynchronous executed commands for RediSearch functionality
@@ -18,22 +20,23 @@
1820
* @param <V> Value type.
1921
* @author Tihomir Mateev
2022
* @see <a href="https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/search/">RediSearch</a>
21-
* @since 6.6
23+
* @since 6.8
2224
* @generated by io.lettuce.apigenerator.CreateAsyncApi
2325
*/
2426
public interface RediSearchAsyncCommands<K, V> {
2527

2628
/**
27-
* Create a new index with the given name, index options, and fields.
29+
* Create a new index with the given name, creation arguments, and fieldArgs.
2830
*
2931
* @param index the index name, as a key
30-
* @param options the index {@link CreateArgs}
31-
* @param fields the {@link Field}s of the index
32+
* @param arguments the index {@link CreateArgs}
33+
* @param fieldArgs the {@link FieldArgs}s of the index
3234
* @return the result of the create command
33-
* @since 6.6
35+
* @since 6.8
3436
* @see <a href="https://redis.io/docs/latest/commands/ft.create/">FT.CREATE</a>
37+
* @see CreateArgs
3538
*/
36-
RedisFuture<String> ftCreate(K index, CreateArgs<K, V> options, List<Field<K>> fields);
39+
RedisFuture<String> ftCreate(K index, CreateArgs<K, V> arguments, List<FieldArgs<K>> fieldArgs);
3740

3841
/**
3942
* Drop an index.
@@ -47,9 +50,23 @@ public interface RediSearchAsyncCommands<K, V> {
4750
* @param index the index name, as a key
4851
* @param deleteDocuments if true, delete the documents as well
4952
* @return the result of the drop command
50-
* @since 6.6
53+
* @since 6.8
5154
* @see <a href="https://redis.io/docs/latest/commands/ft.dropindex/">FT.DROPINDEX</a>
5255
*/
5356
RedisFuture<String> ftDropindex(K index, boolean deleteDocuments);
5457

58+
/**
59+
* Search the index with a textual query, returning either documents or just identifiers
60+
*
61+
* @param index the index name, as a key
62+
* @param query the query string
63+
* @param args the search arguments
64+
* @return the result of the search command, see {@link SearchResults}
65+
* @since 6.8
66+
* @see <a href="https://redis.io/docs/latest/commands/ft.search/">FT.SEARCH</a>
67+
* @see SearchResults
68+
* @see SearchArgs
69+
*/
70+
RedisFuture<SearchResults<K, V>> ftSearch(K index, V query, SearchArgs<K, V> args);
71+
5572
}

src/main/java/io/lettuce/core/api/async/RedisAsyncCommands.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ public interface RedisAsyncCommands<K, V> extends BaseRedisAsyncCommands<K, V>,
3838
RedisHashAsyncCommands<K, V>, RedisHLLAsyncCommands<K, V>, RedisKeyAsyncCommands<K, V>, RedisListAsyncCommands<K, V>,
3939
RedisScriptingAsyncCommands<K, V>, RedisServerAsyncCommands<K, V>, RedisSetAsyncCommands<K, V>,
4040
RedisSortedSetAsyncCommands<K, V>, RedisStreamAsyncCommands<K, V>, RedisStringAsyncCommands<K, V>,
41-
RedisTransactionalAsyncCommands<K, V>, RedisJsonAsyncCommands<K, V>, RedisVectorSetAsyncCommands<K, V> , RediSearchAsyncCommands<K, V> {
41+
RedisTransactionalAsyncCommands<K, V>, RedisJsonAsyncCommands<K, V>, RedisVectorSetAsyncCommands<K, V>,
42+
RediSearchAsyncCommands<K, V> {
4243

4344
/**
4445
* Authenticate to the server.

src/main/java/io/lettuce/core/api/reactive/RediSearchReactiveCommands.java

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@
77
package io.lettuce.core.api.reactive;
88

99
import java.util.List;
10-
import io.lettuce.core.search.Field;
10+
11+
import io.lettuce.core.search.SearchResults;
1112
import io.lettuce.core.search.arguments.CreateArgs;
13+
import io.lettuce.core.search.arguments.FieldArgs;
14+
import io.lettuce.core.search.arguments.SearchArgs;
1215
import reactor.core.publisher.Mono;
1316

1417
/**
@@ -18,22 +21,23 @@
1821
* @param <V> Value type.
1922
* @author Tihomir Mateev
2023
* @see <a href="https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/search/">RediSearch</a>
21-
* @since 6.6
24+
* @since 6.8
2225
* @generated by io.lettuce.apigenerator.CreateReactiveApi
2326
*/
2427
public interface RediSearchReactiveCommands<K, V> {
2528

2629
/**
27-
* Create a new index with the given name, index options, and fields.
30+
* Create a new index with the given name, creation arguments, and fieldArgs.
2831
*
2932
* @param index the index name, as a key
30-
* @param options the index {@link CreateArgs}
31-
* @param fields the {@link Field}s of the index
33+
* @param arguments the index {@link CreateArgs}
34+
* @param fieldArgs the {@link FieldArgs}s of the index
3235
* @return the result of the create command
33-
* @since 6.6
36+
* @since 6.8
3437
* @see <a href="https://redis.io/docs/latest/commands/ft.create/">FT.CREATE</a>
38+
* @see CreateArgs
3539
*/
36-
Mono<String> ftCreate(K index, CreateArgs<K, V> options, List<Field<K>> fields);
40+
Mono<String> ftCreate(K index, CreateArgs<K, V> arguments, List<FieldArgs<K>> fieldArgs);
3741

3842
/**
3943
* Drop an index.
@@ -47,9 +51,23 @@ public interface RediSearchReactiveCommands<K, V> {
4751
* @param index the index name, as a key
4852
* @param deleteDocuments if true, delete the documents as well
4953
* @return the result of the drop command
50-
* @since 6.6
54+
* @since 6.8
5155
* @see <a href="https://redis.io/docs/latest/commands/ft.dropindex/">FT.DROPINDEX</a>
5256
*/
5357
Mono<String> ftDropindex(K index, boolean deleteDocuments);
5458

59+
/**
60+
* Search the index with a textual query, returning either documents or just identifiers
61+
*
62+
* @param index the index name, as a key
63+
* @param query the query string
64+
* @param args the search arguments
65+
* @return the result of the search command, see {@link SearchResults}
66+
* @since 6.8
67+
* @see <a href="https://redis.io/docs/latest/commands/ft.search/">FT.SEARCH</a>
68+
* @see SearchResults
69+
* @see SearchArgs
70+
*/
71+
Mono<SearchResults<K, V>> ftSearch(K index, V query, SearchArgs<K, V> args);
72+
5573
}

src/main/java/io/lettuce/core/api/reactive/RedisReactiveCommands.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@
3131
* @author Mark Paluch
3232
* @since 5.0
3333
*/
34-
public interface RedisReactiveCommands<K, V>
35-
extends BaseRedisReactiveCommands<K, V>, RedisAclReactiveCommands<K, V>, RedisClusterReactiveCommands<K, V>,
36-
RedisFunctionReactiveCommands<K, V>, RedisGeoReactiveCommands<K, V>, RedisHashReactiveCommands<K, V>,
37-
RedisHLLReactiveCommands<K, V>, RedisKeyReactiveCommands<K, V>, RedisListReactiveCommands<K, V>,
38-
RedisScriptingReactiveCommands<K, V>, RedisServerReactiveCommands<K, V>, RedisSetReactiveCommands<K, V>,
39-
RedisSortedSetReactiveCommands<K, V>, RedisStreamReactiveCommands<K, V>, RedisStringReactiveCommands<K, V>,
40-
RedisTransactionalReactiveCommands<K, V>, RedisJsonReactiveCommands<K, V>, RedisVectorSetReactiveCommands<K, V> , RediSearchReactiveCommands<K, V> {
34+
public interface RedisReactiveCommands<K, V> extends BaseRedisReactiveCommands<K, V>, RedisAclReactiveCommands<K, V>,
35+
RedisClusterReactiveCommands<K, V>, RedisFunctionReactiveCommands<K, V>, RedisGeoReactiveCommands<K, V>,
36+
RedisHashReactiveCommands<K, V>, RedisHLLReactiveCommands<K, V>, RedisKeyReactiveCommands<K, V>,
37+
RedisListReactiveCommands<K, V>, RedisScriptingReactiveCommands<K, V>, RedisServerReactiveCommands<K, V>,
38+
RedisSetReactiveCommands<K, V>, RedisSortedSetReactiveCommands<K, V>, RedisStreamReactiveCommands<K, V>,
39+
RedisStringReactiveCommands<K, V>, RedisTransactionalReactiveCommands<K, V>, RedisJsonReactiveCommands<K, V>,
40+
RedisVectorSetReactiveCommands<K, V>, RediSearchReactiveCommands<K, V> {
4141

4242
/**
4343
* Authenticate to the server.

0 commit comments

Comments
 (0)