简体   繁体   English

Solr过滤器中的特殊字符fq

[英]Special characters in Solr filter fq

I'm trying to filter with fq for fields having special characters, particularly parentheses. 我正在尝试使用fq过滤具有特殊字符的字段,尤其是括号。 For example, given the document: 例如,给定文件:

<result name="response" numFound="1" start="0">
  <doc>
    <arr name="town_snc">
      <str>Hartford (Connecticut)</str>
    </arr>
  </doc>
</result>

I want to do eg ?fq:town_snc=Hartford (Connecticut) 我想做什么?fq:town_snc=Hartford (Connecticut)

I'm not getting any results; 我没有得到任何结果; I presume that the parentheses need to be escaped, but I was not able to find the escaping method. 我认为括号需要转义,但我无法找到转义方法。

Thank you! 谢谢!

Using the "field" qparser allows you to not have to do any escaping: 使用“field”qparser可以让你不必进行任何转义:

fq={!field f=town_snc}Hartford (Connecticut)

Or you can use the normal lucene query parser and use double quotes (but then you must still escape some things like quotes) 或者您可以使用普通的lucene查询解析器并使用双引号(但是您仍然必须转义某些内容,如引号)

fq=town_snc:"Hartford (Connecticut)"

Or you could use backslash escaping too (just remember to also escape the space). 或者你也可以使用反斜杠转义(只记得也逃避空间)。

http://wiki.apache.org/solr/SolrQuerySyntax http://wiki.apache.org/solr/SolrQuerySyntax

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM