0

我为搜索操作创建了一个用户界面。在那个用户需要选择过滤器值,他也可以搜索一个特定的关键字。

例如。如果用户选择按国家(例如美国和印度)过滤并搜索关键字“街道”,我必须得到包含“街道”的结果,国家也应该是“美国”或“印度”。

如何使用 solr 实现这一点,以便用户可以为同一字段选择任意数量的过滤器值?

**http://localhost:8983/solr/acc_sea/select?fl=Address_Line_1,Address_Line_2,City,State,Zip,Country,Account_Name,Account_Code,Phone_Number,BIN_Number&fq=Country:"+filtervalue+"&indent=on&q="+searchParam+"&wt=json**

我们完全不知道用户给出了多少过滤器值。solr如何分析并给出结果?

4

1 回答 1

1

Solr 支持布尔查询。即您可以安全地使用 Country:(USA OR INDIA) 。

查看性能,您可能希望单独缓存这些结果集。在这种情况下,您可能更喜欢使用: Country: filter(Country:USA) OR filter(Country:INDIA) [1]

[1] https://cwiki.apache.org/confluence/display/solr/The+Standard+Query+Parser#TheStandardQueryParser-LuceneQueryParser和theSolrStandardQueryParser之间的差异

于 2017-04-24T11:00:23.627 回答