Skip to content

Commit 3bac4d2

Browse files
committed
Implement the FT.CURSOR command
Add Integration tests for the FT.CURSOR Add RESP2 tests for all aggragation integration tests
1 parent 6bc687c commit 3bac4d2

19 files changed

+2974
-240
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,6 +1568,21 @@ public RedisFuture<SearchReply<K, V>> ftAggregate(K index, V query) {
15681568
return dispatch(searchCommandBuilder.ftAggregate(index, query, null));
15691569
}
15701570

1571+
@Override
1572+
public RedisFuture<SearchReply<K, V>> ftCursorread(K index, long cursorId, int count) {
1573+
return dispatch(searchCommandBuilder.ftCursorread(index, cursorId, count));
1574+
}
1575+
1576+
@Override
1577+
public RedisFuture<SearchReply<K, V>> ftCursorread(K index, long cursorId) {
1578+
return dispatch(searchCommandBuilder.ftCursorread(index, cursorId));
1579+
}
1580+
1581+
@Override
1582+
public RedisFuture<String> ftCursordel(K index, long cursorId) {
1583+
return dispatch(searchCommandBuilder.ftCursordel(index, cursorId));
1584+
}
1585+
15711586
@Override
15721587
public RedisFuture<List<Long>> jsonArrappend(K key, JsonPath jsonPath, JsonValue... values) {
15731588
return dispatch(jsonCommandBuilder.jsonArrappend(key, jsonPath, values));

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,6 +1603,11 @@ public Mono<String> ftCreate(K index, List<FieldArgs<K>> fieldArgs) {
16031603
return createMono(() -> searchCommandBuilder.ftCreate(index, null, fieldArgs));
16041604
}
16051605

1606+
@Override
1607+
public Mono<String> ftCursordel(K index, long cursorId) {
1608+
return createMono(() -> searchCommandBuilder.ftCursordel(index, cursorId));
1609+
}
1610+
16061611
@Override
16071612
public Mono<String> ftDropindex(K index, boolean deleteDocumentKeys) {
16081613
return createMono(() -> searchCommandBuilder.ftDropindex(index, deleteDocumentKeys));
@@ -1633,6 +1638,16 @@ public Mono<SearchReply<K, V>> ftAggregate(K index, V query) {
16331638
return createMono(() -> searchCommandBuilder.ftAggregate(index, query, null));
16341639
}
16351640

1641+
@Override
1642+
public Mono<SearchReply<K, V>> ftCursorread(K index, long cursorId, int count) {
1643+
return createMono(() -> searchCommandBuilder.ftCursorread(index, cursorId, count));
1644+
}
1645+
1646+
@Override
1647+
public Mono<SearchReply<K, V>> ftCursorread(K index, long cursorId) {
1648+
return createMono(() -> searchCommandBuilder.ftCursorread(index, cursorId));
1649+
}
1650+
16361651
@Override
16371652
public Flux<Long> jsonArrappend(K key, JsonPath jsonPath, JsonValue... values) {
16381653
return createDissolvingFlux(() -> jsonCommandBuilder.jsonArrappend(key, jsonPath, values));

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

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,57 @@ public Command<K, V, SearchReply<K, V>> ftAggregate(K index, V query, AggregateA
109109
return createCommand(FT_AGGREGATE, new EncodedComplexOutput<>(codec, new SearchReplyParser<>(codec, null)), args);
110110
}
111111

112+
/**
113+
* Read next results from an existing cursor.
114+
*
115+
* @param index the index name
116+
* @param cursorId the cursor id
117+
* @param count the number of results to read
118+
* @return the result of the cursor read command
119+
*/
120+
public Command<K, V, SearchReply<K, V>> ftCursorread(K index, long cursorId, int count) {
121+
notNullKey(index);
122+
123+
CommandArgs<K, V> args = new CommandArgs<>(codec).add(CommandKeyword.READ).addKey(index);
124+
args.add(cursorId);
125+
args.add(CommandKeyword.COUNT);
126+
args.add(count);
127+
128+
return createCommand(FT_CURSOR, new EncodedComplexOutput<>(codec, new SearchReplyParser<>(codec, null)), args);
129+
}
130+
131+
/**
132+
* Read next results from an existing cursor.
133+
*
134+
* @param index the index name
135+
* @param cursorId the cursor id
136+
* @return the result of the cursor read command
137+
*/
138+
public Command<K, V, SearchReply<K, V>> ftCursorread(K index, long cursorId) {
139+
notNullKey(index);
140+
141+
CommandArgs<K, V> args = new CommandArgs<>(codec).add(CommandKeyword.READ).addKey(index);
142+
args.add(cursorId);
143+
144+
return createCommand(FT_CURSOR, new EncodedComplexOutput<>(codec, new SearchReplyParser<>(codec, null)), args);
145+
}
146+
147+
/**
148+
* Delete a cursor.
149+
*
150+
* @param index the index name
151+
* @param cursorId the cursor id
152+
* @return the result of the cursor delete command
153+
*/
154+
public Command<K, V, String> ftCursordel(K index, long cursorId) {
155+
notNullKey(index);
156+
157+
CommandArgs<K, V> args = new CommandArgs<>(codec).add(CommandKeyword.DEL).addKey(index);
158+
args.add(cursorId);
159+
160+
return createCommand(FT_CURSOR, new StatusOutput<>(codec), args);
161+
}
162+
112163
/**
113164
* Drop the index with the given name.
114165
*

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import static io.lettuce.core.protocol.CommandKeyword.*;
4747
import static io.lettuce.core.protocol.CommandType.*;
4848
import static io.lettuce.core.protocol.CommandType.COPY;
49+
import static io.lettuce.core.protocol.CommandType.DEL;
4950
import static io.lettuce.core.protocol.CommandType.SAVE;
5051

5152
/**

0 commit comments

Comments
 (0)