使用原始数据并联合多个方面值的 SOLR 查询
我正在编写用于分面搜索的 SOLR 查询,并且我的字段中可能包含引号或其他不良字符,因此我使用原始运算符来构造查询。但是,如果用户选择多个方面值,我将看不到如何在查询中使用 OR。
例如,以下内容返回 Nike 制造商的结果:
{!raw f=Manufacturer}Nike
以下内容仅返回 Adidas 制造商的结果:
{!raw f=Manufacturer}Nike OR {!raw f=Manufacturer}Adidas
以下内容不返回任何结果:
{!raw f=Manufacturer}Nike OR Adidas
有办法做到这一点吗?
I am writing a SOLR query for faceted searching, and my fields can possibly have quotes or other bad characters in them, so I am using the raw operator to construct the query. However, if the user selects multiple facet values, I can't see how to use an OR in the query.
For example, the following returns results for a Manufacturer of Nike:
{!raw f=Manufacturer}Nike
The following returns results only for a Manufacturer of Adidas:
{!raw f=Manufacturer}Nike OR {!raw f=Manufacturer}Adidas
And the following returns no results:
{!raw f=Manufacturer}Nike OR Adidas
Is there a way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否考虑过转义特殊字符,而不是使用原始运算符?
http://lucene.apache.org/java/2_4_0/queryparsersyntax .html#Escaping%20Special%20Characters
转义的实现非常简单,OR 运算符应该按预期工作。
以下是如何转义 PHP 中的特殊字符的示例:
来源:http://e-mats.org/2010/01/escaping-characters-in-a-solr-query-solr-url/
Have you considered escaping the special characters, instead of using the raw operator?
http://lucene.apache.org/java/2_4_0/queryparsersyntax.html#Escaping%20Special%20Characters
Escaping is pretty trivial to implement and the OR operator should work as expected.
Here's an example of how to escape the special characters in PHP:
Source: http://e-mats.org/2010/01/escaping-characters-in-a-solr-query-solr-url/