Skip to content

Commit e3afb06

Browse files
authored
Add support for FT.DROPINDEX #2722 (#3164)
* Add support for FT.DROPINDEX #2722 * Polishing
1 parent fcb7a1f commit e3afb06

File tree

16 files changed

+183
-4
lines changed

16 files changed

+183
-4
lines changed

.github/workflows/integration.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ on:
88
branches:
99
- main
1010
- '[0-9].*'
11+
- 'feature/*'
1112
pull_request:
1213
branches:
1314
- main
1415
- '[0-9].*'
16+
- 'feature/*'
1517
schedule:
1618
- cron: '0 1 * * *' # nightly build
1719
workflow_dispatch:

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1489,6 +1489,11 @@ public RedisFuture<String> ftCreate(K index, CreateArgs<K, V> options, List<Fiel
14891489
return dispatch(searchCommandBuilder.ftCreate(index, options, fields));
14901490
}
14911491

1492+
@Override
1493+
public RedisFuture<String> ftDropindex(K index, boolean deleteDocumentKeys) {
1494+
return dispatch(searchCommandBuilder.ftDropindex(index, deleteDocumentKeys));
1495+
}
1496+
14921497
@Override
14931498
public RedisFuture<List<Long>> jsonArrappend(K key, JsonPath jsonPath, JsonValue... values) {
14941499
return dispatch(jsonCommandBuilder.jsonArrappend(key, jsonPath, values));

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,6 +1553,11 @@ public Mono<String> ftCreate(K index, CreateArgs<K, V> options, List<Field<K>> f
15531553
return createMono(() -> searchCommandBuilder.ftCreate(index, options, fields));
15541554
}
15551555

1556+
@Override
1557+
public Mono<String> ftDropindex(K index, boolean deleteDocumentKeys) {
1558+
return createMono(() -> searchCommandBuilder.ftDropindex(index, deleteDocumentKeys));
1559+
}
1560+
15561561
@Override
15571562
public Flux<Long> jsonArrappend(K key, JsonPath jsonPath, JsonValue... values) {
15581563
return createDissolvingFlux(() -> jsonCommandBuilder.jsonArrappend(key, jsonPath, values));

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import io.lettuce.core.protocol.Command;
1313
import io.lettuce.core.protocol.CommandArgs;
1414
import io.lettuce.core.protocol.CommandKeyword;
15+
import io.lettuce.core.protocol.RedisCommand;
1516
import io.lettuce.core.search.arguments.CreateArgs;
1617
import io.lettuce.core.search.Field;
1718

@@ -60,4 +61,23 @@ public Command<K, V, String> ftCreate(K index, CreateArgs<K, V> createArgs, List
6061

6162
}
6263

64+
/**
65+
* Drop the index with the given name.
66+
*
67+
* @param index the index name
68+
* @param deleteDocumentKeys whether to delete the document keys
69+
* @return the result of the drop command
70+
*/
71+
public Command<K, V, String> ftDropindex(K index, boolean deleteDocumentKeys) {
72+
notNullKey(index);
73+
74+
CommandArgs<K, V> args = new CommandArgs<>(codec).addKey(index);
75+
76+
if (deleteDocumentKeys) {
77+
args.add(CommandKeyword.DD);
78+
}
79+
80+
return createCommand(FT_DROPINDEX, new StatusOutput<>(codec), args);
81+
}
82+
6383
}

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,21 @@ public interface RediSearchAsyncCommands<K, V> {
3535
*/
3636
RedisFuture<String> ftCreate(K index, CreateArgs<K, V> options, List<Field<K>> fields);
3737

38+
/**
39+
* Drop an index.
40+
* <p/>
41+
* By default, <a href="https://redis.io/docs/latest/commands/ft.dropindex/">FT.DROPINDEX</a> does not delete the documents
42+
* associated with the index. Adding the <code>deleteDocuments</code> option deletes the documents as well. If an index
43+
* creation is still running (<a href="https://redis.io/docs/latest/commands/ft.create/">FT.CREATE</a> is running
44+
* asynchronously), only the document hashes that have already been indexed are deleted. The document hashes left to be
45+
* indexed remain in the database.
46+
*
47+
* @param index the index name, as a key
48+
* @param deleteDocuments if true, delete the documents as well
49+
* @return the result of the drop command
50+
* @since 6.6
51+
* @see <a href="https://redis.io/docs/latest/commands/ft.dropindex/">FT.DROPINDEX</a>
52+
*/
53+
RedisFuture<String> ftDropindex(K index, boolean deleteDocuments);
54+
3855
}

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,21 @@ public interface RediSearchReactiveCommands<K, V> {
3535
*/
3636
Mono<String> ftCreate(K index, CreateArgs<K, V> options, List<Field<K>> fields);
3737

38+
/**
39+
* Drop an index.
40+
* <p/>
41+
* By default, <a href="https://redis.io/docs/latest/commands/ft.dropindex/">FT.DROPINDEX</a> does not delete the documents
42+
* associated with the index. Adding the <code>deleteDocuments</code> option deletes the documents as well. If an index
43+
* creation is still running (<a href="https://redis.io/docs/latest/commands/ft.create/">FT.CREATE</a> is running
44+
* asynchronously), only the document hashes that have already been indexed are deleted. The document hashes left to be
45+
* indexed remain in the database.
46+
*
47+
* @param index the index name, as a key
48+
* @param deleteDocuments if true, delete the documents as well
49+
* @return the result of the drop command
50+
* @since 6.6
51+
* @see <a href="https://redis.io/docs/latest/commands/ft.dropindex/">FT.DROPINDEX</a>
52+
*/
53+
Mono<String> ftDropindex(K index, boolean deleteDocuments);
54+
3855
}

src/main/java/io/lettuce/core/api/sync/RediSearchCommands.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,21 @@ public interface RediSearchCommands<K, V> {
3434
*/
3535
String ftCreate(K index, CreateArgs<K, V> options, List<Field<K>> fields);
3636

37+
/**
38+
* Drop an index.
39+
* <p/>
40+
* By default, <a href="https://redis.io/docs/latest/commands/ft.dropindex/">FT.DROPINDEX</a> does not delete the documents
41+
* associated with the index. Adding the <code>deleteDocuments</code> option deletes the documents as well. If an index
42+
* creation is still running (<a href="https://redis.io/docs/latest/commands/ft.create/">FT.CREATE</a> is running
43+
* asynchronously), only the document hashes that have already been indexed are deleted. The document hashes left to be
44+
* indexed remain in the database.
45+
*
46+
* @param index the index name, as a key
47+
* @param deleteDocuments if true, delete the documents as well
48+
* @return the result of the drop command
49+
* @since 6.6
50+
* @see <a href="https://redis.io/docs/latest/commands/ft.dropindex/">FT.DROPINDEX</a>
51+
*/
52+
String ftDropindex(K index, boolean deleteDocuments);
53+
3754
}

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,21 @@ public interface RediSearchAsyncCommands<K, V> {
3434
*/
3535
AsyncExecutions<String> ftCreate(K index, CreateArgs<K, V> options, List<Field<K>> fields);
3636

37+
/**
38+
* Drop an index.
39+
* <p/>
40+
* By default, <a href="https://redis.io/docs/latest/commands/ft.dropindex/">FT.DROPINDEX</a> does not delete the documents
41+
* associated with the index. Adding the <code>deleteDocuments</code> option deletes the documents as well. If an index
42+
* creation is still running (<a href="https://redis.io/docs/latest/commands/ft.create/">FT.CREATE</a> is running
43+
* asynchronously), only the document hashes that have already been indexed are deleted. The document hashes left to be
44+
* indexed remain in the database.
45+
*
46+
* @param index the index name, as a key
47+
* @param deleteDocuments if true, delete the documents as well
48+
* @return the result of the drop command
49+
* @since 6.6
50+
* @see <a href="https://redis.io/docs/latest/commands/ft.dropindex/">FT.DROPINDEX</a>
51+
*/
52+
AsyncExecutions<String> ftDropindex(K index, boolean deleteDocuments);
53+
3754
}

src/main/java/io/lettuce/core/cluster/api/sync/RediSearchCommands.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,21 @@ public interface RediSearchCommands<K, V> {
3434
*/
3535
Executions<String> ftCreate(K index, CreateArgs<K, V> options, List<Field<K>> fields);
3636

37+
/**
38+
* Drop an index.
39+
* <p/>
40+
* By default, <a href="https://redis.io/docs/latest/commands/ft.dropindex/">FT.DROPINDEX</a> does not delete the documents
41+
* associated with the index. Adding the <code>deleteDocuments</code> option deletes the documents as well. If an index
42+
* creation is still running (<a href="https://redis.io/docs/latest/commands/ft.create/">FT.CREATE</a> is running
43+
* asynchronously), only the document hashes that have already been indexed are deleted. The document hashes left to be
44+
* indexed remain in the database.
45+
*
46+
* @param index the index name, as a key
47+
* @param deleteDocuments if true, delete the documents as well
48+
* @return the result of the drop command
49+
* @since 6.6
50+
* @see <a href="https://redis.io/docs/latest/commands/ft.dropindex/">FT.DROPINDEX</a>
51+
*/
52+
Executions<String> ftDropindex(K index, boolean deleteDocuments);
53+
3754
}

src/main/java/io/lettuce/core/protocol/CommandKeyword.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public enum CommandKeyword implements ProtocolKeyword {
5353

5454
MAXTEXTFIELDS, PREFIX, FILTER, LANGUAGE, LANGUAGE_FIELD, SCORE, SCORE_FIELD, PAYLOAD_FIELD, TEMPORARY, NOOFFSETS, NOHL, NOFIELDS, NOFREQS, SKIPINITIALSCAN, STOPWORDS, AS, SORTABLE, SCHEMA, UNF, NOINDEX,
5555

56-
NOSTEM, PHONETIC, WEIGHT, SEPARATOR, CASESENSITIVE, WITHSUFFIXTRIE, INDEXEMPTY, INDEXMISSING;
56+
NOSTEM, PHONETIC, WEIGHT, SEPARATOR, CASESENSITIVE, WITHSUFFIXTRIE, INDEXEMPTY, INDEXMISSING, DD;
5757

5858
public final byte[] bytes;
5959

0 commit comments

Comments
 (0)