尝试通过生菜(Java)将RedisTimeSeries命令发送到Redis。它适用于简单的命令,例如TS.Create,但是我无法使用更复杂的命令(例如TS.ADD,将键,分数,值作为args)或TS.Range(将args并返回List)工作。
Redis在Linux上运行(Ubuntu在Windows 10上通过WSL运行),RedisTimeSeries安装在Redis上。 Redis和RedisTimeSeries命令已经在Linux上使用Redis-cli进行了测试,它们可以正常工作。我使用VS Code + JDK 13.0 + Maven为Redis构建和测试Java客户端。到目前为止,Lettuce支持的Redis命令可以通过客户端运行,以及一些简单的RedisTimeSeries命令。
代码段:
{A},
{B},
{C},
{ABC},
{DEF},
{1},
{2},
{34},
etc.
但是当我切换所有内容以测试TS.ADD时,即使我相应地添加了其他args,它也无法正常工作。 例如
<script>
var link = '<img src="path_to_IMG" height="15px" width="15px">';
$("body").children().each(function () {
$(this).html( $(this).html().replace(/{B}/g, link) );
});
</script>
这是运行中的例外情况:
<script>
$path = 'website.com/images/';
$img_loc = 'IMG_GENERIC.png';
$link = '<img src=".$path.$img_loc." alt="symbol" height="15px" width="15px" />';
$("body").children().each(function ()
{
case('{A}'):
$img_loc = 'IMG_A.png';
$(this).html( $(this).html().replace(/{A}/g, link) );
case('{B}'):
$img_loc = 'IMG_B.png';
$(this).html( $(this).html().replace(/{B}/g, link) );
});
</script>
答案 0 :(得分:1)
很抱歉看到这么晚。如果您还没有找到解决方案,那么我最初是使用动态命令来实现RediSearch命令的。
public interface RediSearchCommands extends Commands {
@Command("FT.SUGADD ?0 ?1 ?2")
Long sugadd(String key, String string, double score);
...
}
public void testSuggestions() {
RedisCommandFactory factory = new RedisCommandFactory(client.connect());
RediSearchCommands commands = factory.getCommands(RediSearchCommands.class);
commands.sugadd(key, "Herbie Hancock", 1.0);
}
完整来源:https://github.com/RediSearch/lettusearch/commit/567de42c147e0f07184df444cd1ae9798ae2514e