When doing range faceting, it’s sometimes useful to match documents for which a given field is within one of multiple ranges.
The current syntax is a bit cumbersome:
{noformat}f -> f.bool(b -> { for (Range<Integer> range : rangesToMatch) { b.should(f.range().field("myField").range(range)) } }){noformat}
Let’s introduce a syntax that will accept multiple ranges, and create the underlying boolean query transparently:
{noformat}f -> f.range().field("myField").withinAny(rangesToMatch){noformat}
I think {{withinAny}} would be a better name for this method than {{ranges}}, because a trailing {{s}} is easily overlooked. Also, {{f.range().field("myField").ranges(...)}} is really far from natural language.
For consistency, we should add a {{withinRangewithin}} method to replace the {{range}} method, and deprecate the {{range}} method. |
|