我在单个 Redisearch 上使用多个索引,每个索引都与代码中的一个类相关联。例如,XYZ ( List<XYZ>
) 的数据通过索引 XYZ 保存,而 ABC ( List<ABC>
) 的数据通过 ABC 保存。
问题是,当我使用索引 XYZ 搜索 XYZ 的数据时,ABC 的数据也会出现在搜索中。这可以像这样轻松地重新创建:
//declare three indexes. Some of them contain duplicate field names but this is to be expected (in real life we would have things like timestamps that spread across indexes)
ft.create sample1 schema sampletext text
ft.create sample2 schema sampleinteger numeric sortable
ft.create sample3 schema sampletext text sampleinteger numeric
//then we add a text under sample1
ft.add sample1 sample1doc 1.0 fields sampletext "hello this document is under an index called sample1"
//then display all the documents associated with the index sample3
ft.search "sample3" "*"
//-> prints the document above "hello this document is under..."
//display all the documents associated with the index sample2
ft.search "sample2" "*"
//-> the same result
为什么是这样?有什么好的解决方法吗?
我知道 FT.ADD 现在已弃用,但 C# 库仍在内部调用 FT.ADD,因此我需要让它与 FT.ADD 一起使用,而且我们刚刚添加的文档仅包含“sampletext”,因此它仍然不应该出现在 sample2 下反正。