小编Mav*_*lin的帖子

搜索Solr索引时避免重复

我的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型文档。

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

solr filtering duplicate-removal solr-query-syntax

4
推荐指数
1
解决办法
3875
查看次数