solr-node-client icon indicating copy to clipboard operation
solr-node-client copied to clipboard

range-filter queries should support exclusive boundaries

Open marc-portier opened this issue 10 years ago • 1 comments

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

marc-portier avatar Oct 23 '14 20:10 marc-portier

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.

lbdremy avatar Oct 24 '14 21:10 lbdremy