Switch Query Parser – quick look | Solr Enterprise Search
Logic behind the parser
The logic of the SwitchQueryParser is quite simple – allow processing a simple logic on the Solr side and add it as a sub-query. For example let’s say that we have an application that understand the following four values of the priceRangefield:
- cheap – when the price of the product (indexed in the price field) is lower than 10$,
- average – when the price is between 10 and 30$,
- expensive – when the product price is higher than 30$,
- all – in case we want to return all the documents without looking at the price.
We want to have this logic stored in Solr somehow in order not to change our application or its configuration every time we want to change the above ranges.
http://localhost:8983/solr/collection1/price?q=*:*&priceRange=cheap
< requestHandler name = "/price" > |
3 | < str name = "priceRange" >all</ str > |
6 | < str name = "fq" >{!switch case.all='price:[* TO *]' case.cheap='price:[0 TO 10]' case.average='price:[10 TO 30]' case.expensive='price:[30 TO *]' v=$priceRange}</ str > |
Read full article from
Switch Query Parser – quick look | Solr Enterprise Search
No comments:
Post a Comment