开发者

Special characters in Solr filter fq

开发者 https://www.devze.com 2023-02-15 22:09 出处:网络
I\'m trying to filter with fq for fields having special characters, particularly parentheses.For exam开发者_StackOverflow社区ple, given the document:

I'm trying to filter with fq for fields having special characters, particularly parentheses. For exam开发者_StackOverflow社区ple, 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 e.g. ?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:

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)

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号