You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Attempting to sort a search on a integer_range field provides inconsistent results, some searches will be successful, but then if a specific document is in the results, will fail with an exception as follows:
From Slack discussion (will purge after 90 days) so including explanation below:
oye! tldr; sorting by range fields is unexpected behavior.
Looks like Elastic mucked that one up pretty good. I should've explicitly stated this when I wrote the blog post years ago.
I initially removed doc value support for RangeFields when I first added the field to Elasticsearch, only because
we didn't have any aggregation support for range fields. They were added back not long after in order to boost
query performance using IndexOrDocValuesQuery, but the nasty side effect is that Sort also uses doc values,
and no guard rails were included in the commit. So what's happening is the integer range encoding of the value
to doc value is variable (to save space on disk since S3 is expensive 🙂 ). So when the DocValueFormat instance is pulled from RangeFieldType.docValueFormat it's just using the default RAW
formatter which doesn't take the RangeType into consideration thus tries to blindly decode the encoded
range to a nonsensicle string using BytesRef.utf8ToString welp, as expected the values aren't UTF8
so the UnicodeUtil#UTF8ToUTF16 trips a byte boundary assertion (if you're running with assertions enabled)
and nasty unexpected behaviors ensue 😕
Describe the bug
Attempting to sort a search on a integer_range field provides inconsistent results, some searches will be successful, but then if a specific document is in the results, will fail with an exception as follows:
Related component
Search
To Reproduce
Observe: Search fails with error detailed above.
price_range.lte
):Observe: Search succeeds
Expected behavior
Option 1:
Sorting on
integer_range
should be unsupported, and all searches attempting to do so should fail with a clear error message.Option 2:
Sorting on
integer_range
should allow you to specify an anchor point to sort on (e.g. min,max,median).Additional Details
Plugins
N/A
Screenshots
N/A
Host/Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: