solr-node-client
solr-node-client copied to clipboard
range-filter queries should support exclusive boundaries
The SOLR range-filter syntax allows variants that do not include the boundary values.
year:[2005 TO 2009] will match 2005, 2006, 2007, 2008, 2009 By using [inclusive with square brackets]: The boundaries are included.
year:{2005 TO 2009} will only match 2006, 2007, 2008 By using {exclusive with curly brackets}: The bounds are not included.
year:[2005 TO 2009} will match 2005, 2006, 2007, 2008 By using [mixed inclusive and exclusive} brackets the indicated boundaries will be in or ex-cluded.
We could support this in the query-builder by allowing to pass an extra 'include' parameter in the options object passed.
when include == "lower" or include == "both" we start the expression with [, else { when include == "upper" or include =="both" we end the expression with ], else }
leading to interprete the effect of this new parameter to one of:
- [include = lower},
- {include = upper],
- [include = both],
- {include = none, or whatever unrecognised value}
For backwards-compatibility we should take include="both" as a default. Decent documentation will be needed though:
- the facet-range syntax in SOLR also use a similar include parameter, and assumes "lower" to be the default.
- IMHO the [lower} variant is the most logical one to use (but that's probably because I use it in combination with the range-facets
Hey @marc-portier,
Interesting I did not know about the two different syntax to express a range, where did you find out about this?
Sure your proposition is good, send a pull request I will merge it.