Ensure integer sorts are rewritten to long sorts for BWC indexes#139293
Ensure integer sorts are rewritten to long sorts for BWC indexes#139293elasticsearchmachine merged 8 commits intoelastic:mainfrom
Conversation
|
Pinging @elastic/es-search (Team:Search) |
|
Fixes: #139293 |
|
Hi @romseygeek, I've created a changelog YAML for you. |
|
@romseygeek I think this might also fix this issue: #139275 We saw this NPE on an index created before (thus sorting on long) and then sorting with a new index (sorting on int). |
|
Consequently, what do you think about backporting to 9.2.x (and maybe 9.1.x?)? |
|
This specific bug is only in 9.3 I think, although the fix may also clean up other issues. There have been several changes in IndexNumericFieldData which means this won't be trivial to backport. |
To be clear, that doesn't mean we shouldn't do it! Just that it probably needs to be a separate PR and a different test setup. |
| return FieldSortBuilder.fromXContent(parser, fieldName); | ||
| } | ||
|
|
||
| public void testIntRewritesToLong() throws IOException { |
| ); | ||
|
|
||
| XFieldComparatorSource longSource = comparatorSource(NumericType.LONG, missingValue, sortMode, nested); | ||
| if (sortField instanceof SortedNumericSortField snsf) { |
There was a problem hiding this comment.
For my education, under what condition index sort is not instance of SortedNumericSortField?
Is it something new?
There was a problem hiding this comment.
Index sorts are always SortedNumericSortField instances, but query-time sorts now generally use custom comparators to pick up some performance improvements that are not in a released lucene version, so they are plain SortField instances.
mayya-sharipova
left a comment
There was a problem hiding this comment.
@romseygeek Thanks for a fix!
This specific issue originally involved scroll, so I am not sure. |
|
I'll backport the test to 9.2 and see if it surfaces any issues. |
* upstream/main: (79 commits)
Mute org.elasticsearch.test.rest.yaml.CcsCommonYamlTestSuiteIT test {p0=search/140_pre_filter_search_shards/prefilter on non-indexed date fields} elastic#139381
Adjust error bounds for bfloat16 value checks (elastic#139371)
Unmute some vector CSS tests (elastic#139370)
Do not allow `project_routing` as a query param (elastic#139206)
Unmute HalfFloat...Tests#testSynthesizeArrayRandom (elastic#139341)
Remove leniency in LinkedProjectConfig builder methods (elastic#139012)
EQL: fix project_routing (elastic#139366)
Add patch version for 9.2 index version constant (elastic#139362)
Mute org.elasticsearch.test.rest.yaml.RcsCcsCommonYamlTestSuiteIT test {p0=search.vectors/200_dense_vector_docvalue_fields/dense_vector docvalues with bfloat16} elastic#139368
ES|QL: Enable CCS tests for FORK (elastic#139302)
Restructuring the semantic_text field type page (elastic#138571)
AggregateMetricDouble fields should not build BKD indexes (elastic#138724)
Feature/count by trunc with filter (elastic#138765)
ESQL: Convert TS 500 error to 400 (elastic#139360)
[CI] Rerun failing tests for periodic build pipelines (elastic#139200)
revert muting saml test (elastic#139327)
Add TDigest histogram as metric (elastic#139247)
Links solved bugs to class cast exception changelog and unmutes errors (elastic#139340)
Ensure integer sorts are rewritten to long sorts for BWC indexes (elastic#139293)
Integrate stored fields format bloom filter with synthetic _id (elastic#138515)
...
Backports tests from #139293
Sorts against integer fields in pre-8.19 indexes are rewritten to use LongComparators to stay consistent with pre-written index metadata. These also need to always expect multi-valued fields. elastic#139293 incorrectly built single-valued sorts in certain circumstances, which would then throw runtime errors.
Sorts against integer fields in pre-8.19 indexes are rewritten to use LongComparators to stay consistent with pre-written index metadata. These also need to always expect multi-valued fields. #139293 incorrectly built single-valued sorts in certain circumstances, which would then throw runtime errors.
…39538) Sorts against integer fields in pre-8.19 indexes are rewritten to use LongComparators to stay consistent with pre-written index metadata. These also need to always expect multi-valued fields. elastic#139293 incorrectly built single-valued sorts in certain circumstances, which would then throw runtime errors.
…39538) Sorts against integer fields in pre-8.19 indexes are rewritten to use LongComparators to stay consistent with pre-written index metadata. These also need to always expect multi-valued fields. elastic#139293 incorrectly built single-valued sorts in certain circumstances, which would then throw runtime errors.
…139700) Sorts against integer fields in pre-8.19 indexes are rewritten to use LongComparators to stay consistent with pre-written index metadata. These also need to always expect multi-valued fields. #139293 incorrectly built single-valued sorts in certain circumstances, which would then throw runtime errors.
Older indexes used long sorts for integer fields, and we need to ensure that
sorts against these fields do not conflict. Recent refactoring in
IndexNumericSortField missed a case where this could happen.
Closes #139127
Closes #139128