Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/main/java/io/lettuce/core/AbstractRedisAsyncCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -1559,6 +1559,36 @@ public RedisFuture<String> ftCreate(K index, List<FieldArgs<K>> fieldArgs) {
return dispatch(searchCommandBuilder.ftCreate(index, null, fieldArgs));
}

@Override
public RedisFuture<String> ftAliasadd(K alias, K index) {
return dispatch(searchCommandBuilder.ftAliasadd(alias, index));
}

@Override
public RedisFuture<String> ftAliasupdate(K alias, K index) {
return dispatch(searchCommandBuilder.ftAliasupdate(alias, index));
}

@Override
public RedisFuture<String> ftAliasdel(K alias) {
return dispatch(searchCommandBuilder.ftAliasdel(alias));
}

@Override
public RedisFuture<String> ftAlter(K index, boolean skipInitialScan, List<FieldArgs<K>> fieldArgs) {
return dispatch(searchCommandBuilder.ftAlter(index, skipInitialScan, fieldArgs));
}

@Override
public RedisFuture<List<V>> ftTagvals(K index, K fieldName) {
return dispatch(searchCommandBuilder.ftTagvals(index, fieldName));
}

@Override
public RedisFuture<String> ftAlter(K index, List<FieldArgs<K>> fieldArgs) {
return dispatch(searchCommandBuilder.ftAlter(index, false, fieldArgs));
}

@Override
public RedisFuture<String> ftDropindex(K index, boolean deleteDocumentKeys) {
return dispatch(searchCommandBuilder.ftDropindex(index, deleteDocumentKeys));
Expand Down
30 changes: 30 additions & 0 deletions src/main/java/io/lettuce/core/AbstractRedisReactiveCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -1624,6 +1624,36 @@ public Mono<String> ftCreate(K index, List<FieldArgs<K>> fieldArgs) {
return createMono(() -> searchCommandBuilder.ftCreate(index, null, fieldArgs));
}

@Override
public Mono<String> ftAliasadd(K alias, K index) {
return createMono(() -> searchCommandBuilder.ftAliasadd(alias, index));
}

@Override
public Mono<String> ftAliasupdate(K alias, K index) {
return createMono(() -> searchCommandBuilder.ftAliasupdate(alias, index));
}

@Override
public Mono<String> ftAliasdel(K alias) {
return createMono(() -> searchCommandBuilder.ftAliasdel(alias));
}

@Override
public Mono<String> ftAlter(K index, boolean skipInitialScan, List<FieldArgs<K>> fieldArgs) {
return createMono(() -> searchCommandBuilder.ftAlter(index, skipInitialScan, fieldArgs));
}

@Override
public Flux<V> ftTagvals(K index, K fieldName) {
return createDissolvingFlux(() -> searchCommandBuilder.ftTagvals(index, fieldName));
}

@Override
public Mono<String> ftAlter(K index, List<FieldArgs<K>> fieldArgs) {
return createMono(() -> searchCommandBuilder.ftAlter(index, false, fieldArgs));
}

@Override
public Mono<String> ftCursordel(K index, long cursorId) {
return createMono(() -> searchCommandBuilder.ftCursordel(index, cursorId));
Expand Down
91 changes: 91 additions & 0 deletions src/main/java/io/lettuce/core/RediSearchCommandBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import io.lettuce.core.codec.RedisCodec;
import io.lettuce.core.output.EncodedComplexOutput;
import io.lettuce.core.output.StatusOutput;
import io.lettuce.core.output.ValueListOutput;
import io.lettuce.core.protocol.BaseRedisCommandBuilder;
import io.lettuce.core.protocol.Command;
import io.lettuce.core.protocol.CommandArgs;
Expand Down Expand Up @@ -153,6 +154,96 @@ public Command<K, V, String> ftCursordel(K index, long cursorId) {
return createCommand(FT_CURSOR, new StatusOutput<>(codec), args);
}

/**
* Add an alias to an index.
*
* @param alias the alias name
* @param index the index name
* @return the result of the alias add command
*/
public Command<K, V, String> ftAliasadd(K alias, K index) {
notNullKey(alias);
notNullKey(index);

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

return createCommand(FT_ALIASADD, new StatusOutput<>(codec), args);
}

/**
* Update an alias to point to a different index.
*
* @param alias the alias name
* @param index the index name
* @return the result of the alias update command
*/
public Command<K, V, String> ftAliasupdate(K alias, K index) {
notNullKey(alias);
notNullKey(index);

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

return createCommand(FT_ALIASUPDATE, new StatusOutput<>(codec), args);
}

/**
* Remove an alias from an index.
*
* @param alias the alias name
* @return the result of the alias delete command
*/
public Command<K, V, String> ftAliasdel(K alias) {
notNullKey(alias);

CommandArgs<K, V> args = new CommandArgs<>(codec).addKey(alias);

return createCommand(FT_ALIASDEL, new StatusOutput<>(codec), args);
}

/**
* Add new attributes to an existing index.
*
* @param index the index name
* @param skipInitialScan whether to skip the initial scan of existing documents
* @param fieldArgs the field arguments for the new attributes to add
* @return the result of the alter command
*/
public Command<K, V, String> ftAlter(K index, boolean skipInitialScan, List<FieldArgs<K>> fieldArgs) {
notNullKey(index);
notEmpty(fieldArgs.toArray());

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

if (skipInitialScan) {
args.add(CommandKeyword.SKIPINITIALSCAN);
}

args.add(CommandKeyword.SCHEMA);
args.add(CommandKeyword.ADD);

for (FieldArgs<K> arg : fieldArgs) {
arg.build(args);
}

return createCommand(FT_ALTER, new StatusOutput<>(codec), args);
}

/**
* Return distinct values indexed in a Tag field.
*
* @param index the index name
* @param fieldName the name of a Tag field defined in the schema
* @return the result of the tagvals command
*/
public Command<K, V, List<V>> ftTagvals(K index, K fieldName) {
notNullKey(index);
notNullKey(fieldName);

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

return createCommand(FT_TAGVALS, new ValueListOutput<>(codec), args);
}

/**
* Drop the index with the given name.
*
Expand Down
Loading