I try to obtain FT.SEARCH results in Micronaut using Lettuce annotations like this:
import io.lettuce.core.dynamic.Commands;
import io.lettuce.core.dynamic.annotation.Command;
import java.util.List;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
public interface JsonCommands extends Commands {
@Command("FT.SEARCH ?0 ?1")
Flux<String> jsonFtSearch(final String index, final String query);
@Command("JSON.SET ?0 ?1 ?2")
Mono<String> jsonSet(final String key, final String path, final String json);
@Command("JSON.MGET ?0 $")
Flux<String> jsonMGet(final List<String> keys);
Do I need to write some special converters to retrieve results from jsonFtSearch
? I cannot find a another method but I can't believe there is no other way.
I use Micronaut 4.2.4
, io.lettuce:lettuce-core:6.2.6
.
I try to obtain FT.SEARCH results in Micronaut using Lettuce annotations like this:
import io.lettuce.core.dynamic.Commands;
import io.lettuce.core.dynamic.annotation.Command;
import java.util.List;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
public interface JsonCommands extends Commands {
@Command("FT.SEARCH ?0 ?1")
Flux<String> jsonFtSearch(final String index, final String query);
@Command("JSON.SET ?0 ?1 ?2")
Mono<String> jsonSet(final String key, final String path, final String json);
@Command("JSON.MGET ?0 $")
Flux<String> jsonMGet(final List<String> keys);
Do I need to write some special converters to retrieve results from jsonFtSearch
? I cannot find a another method but I can't believe there is no other way.
I use Micronaut 4.2.4
, io.lettuce:lettuce-core:6.2.6
.
1 Answer
Reset to default 1Important note
The Redis team is currently implementing native support for the search commands (FT.*) that would become a part of Lettuce. You can follow up this process if you track this issue.
Handling response type for custom commands
(as explained in the Lettuce guide)
Custom commands could either use any of the existing converters (CommandOutput class in Lettuce terminology), or you can define your own. In your case, and specifically for FT.SEARCH
you would have to write your own, because the data returned is rather complex and specific to this command.
Side note
I see that in your example there are also JSON.SET
and JSON.MGET
shown. since Lettuce 6.5.0 the JSON commands are all natively supported. If you have the option to use 6.5.0+ then you need not implement your own custom commands.