How to easy obtain REDIS FT.SEARCH in Micronaut using lettuce-core? - Stack Overflow

I try to obtain FT.SEARCH results in Micronaut using Lettuce annotations like this:import io.lettuce.c

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 .

Share Improve this question edited Mar 30 at 7:08 Jonatan Ivanov 7,0462 gold badges18 silver badges33 bronze badges asked Mar 28 at 8:24 digital_infinitydigital_infinity 5646 silver badges24 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

Important 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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744048749a4549678.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信