Incorrect Range Search Query Example in Solr Documentation
19 01 2009Many of you may have seen this exception when trying out Solr’s range search query based on Solr’s documentation.
HTTP Status 400 - org.apache.lucene.queryParser.ParseException: Cannot parse 'rank:[1 to 10]': Encountered "10" at line 1, column 11. Was expecting: "]" ...
This exception is saying that Lucene’s query parser does not recognize a third value “10” in the range filter query. The parser only expects two values. It’s kind of confusing because Solr’s documentation gives an example of “field:[1 to 100]”. Interestingly, the documentation is consistent between Solr and Lucene’s documentation regarding the range search query format:
http://wiki.apache.org/solr/SolrQuerySyntax
http://lucene.apache.org/java/2_4_0/queryparsersyntax.html#Range Searches
As you can see, they both describe range search query’s syntax as
- Return results with value in field “rank” between 1 and 100
- fq=rank:[1 100]
- Return results with value in field “rank” less than or equal to 10
- fq=rank:[* 10]
- Return results with value in field “rank” greater than or equal to 10
- fq=rank:[10 *]
Categories : Bugs