搜索Solr索引时避免重复

Mav*_*lin 4 solr filtering duplicate-removal solr-query-syntax

我的Solr索引有两种类型的用户(Type-A和Type-B),可以用称为“ type”的字段来标识。但是,用户可能同时在Type(A和B)下都有条目。

例如,

Jacob is a user who comes under both Types(A and B). So, he will have two documents in our Index like:  
//document-1  
name:...  
type:A  
age:...  
//end of document-1


//document-2  
name:...  
Type:B  
age:...  
//end of document-2
Run Code Online (Sandbox Code Playgroud)

我的目标是

  • 当搜索用户并且他只是Type-A时,他应该在结果中。

  • 当搜索用户并且他只是B型用户时,他应该在结果中。

  • 当搜索某个用户(例如Jacob)且他同时属于A型和B型时,结果中仅应包含A型文档。

我们如何通过查询实现这一目标?
提前致谢!

Per*_*ium 5

我假设您有一些可以唯一标识用户的字段?像名称还是iduser?如果是这样的话,那就用grouping分组那个字段。如果您设置group.main = true,则结果与未使用分组的结果没有什么不同