为什么 RediSearch FT.AGGREGATE 将条目放入错误的组?

问题描述 投票:0回答:1

我遇到了 Redis RediSearch 模块的问题,我不确定这是一个错误,还是我的误解。我有几个带有问答对的 JSON 文档,如下所示:

// myKey:1
{ 
  "answeredBy": "John",
  "answeredOn": "12 Sep 2023"
  "results": [
    { "question": "Who is a composer?", "answer": "Bach" },
    { "question": "Who is an athlete?", "answer": "Tiger Woods" }
  ]
}
// myKey:2 
{
  "answeredBy": "John", 
  "answeredOn": "24 Oct 2023"
  "results": [
     { "question": "Who is a composer?", "answer": "Bach" }
  ]
}
// etc.

我想查询特定人的所有问题和答案。所以我创建了一个类似

FT.CREATE mySearch ON JSON PREFIX 1 myKey: SCHEMA $.answeredBy AS answeredBy TAG
的搜索。然后我搜索像这样的人的所有答案:
FT.AGGREGATE mySearch @answeredBy:{John} LOAD 6 $.results[*].question AS questions $.results[*].answer AS answers GROUPBY 2 @questions @answers REDUCE COUNT 0 AS numAnswers DIALECT 4

我预计结果会产生两个独特的组,一组代表

["Who is a composer?", "Who is an atlete?"]
,一组代表
["Who is a composer?"]
。然而,实际结果认为两个键的
questions
值是相同的(!)并将它们分组在一起,如下所示:

1) "1"
2) 1) "questions"
   2) "[\"Who is a composer?\", \"Who is an athlete?\"]"
   3) "answers"
   4) "[\"Bach\", "Tiger Woods"]"
   5) "numAnswers"
   6) "2" // <---- THE PROBLEM!! myKey:2 doesn't have the "Who is an athlete?" question, but gets counted as having it. That means the answers count is wrong.

如果数组中的第一个值相同,则

GROUPBY
步骤似乎错误地将单独的值分组在一起。也许情况并非如此,我错误地使用了该函数。将不胜感激任何帮助。

database indexing redis aggregate full-text-search
1个回答
0
投票

这是已知的错误,具有已知的解决方法,不幸的是没有修复日期的指示

https://github.com/RediSearch/RediSearch/issues/3398

© www.soinside.com 2019 - 2024. All rights reserved.