Skip to content

Commit 4880245

Browse files
Fix IndexSortUpgradeIT test (#128900)
Relates to PR #127968 Closes #128861, #128862, #128863
1 parent de40ac4 commit 4880245

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

muted-tests.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -504,15 +504,6 @@ tests:
504504
- class: org.elasticsearch.index.store.DirectIOIT
505505
method: testDirectIOUsed
506506
issue: https://github.com/elastic/elasticsearch/issues/128829
507-
- class: org.elasticsearch.upgrades.IndexSortUpgradeIT
508-
method: testIndexSortForNumericTypes {upgradedNodes=3}
509-
issue: https://github.com/elastic/elasticsearch/issues/128861
510-
- class: org.elasticsearch.upgrades.IndexSortUpgradeIT
511-
method: testIndexSortForNumericTypes {upgradedNodes=1}
512-
issue: https://github.com/elastic/elasticsearch/issues/128862
513-
- class: org.elasticsearch.upgrades.IndexSortUpgradeIT
514-
method: testIndexSortForNumericTypes {upgradedNodes=2}
515-
issue: https://github.com/elastic/elasticsearch/issues/128863
516507
- class: org.elasticsearch.packaging.test.DockerTests
517508
method: test150MachineDependentHeap
518509
issue: https://github.com/elastic/elasticsearch/issues/128120

server/src/main/java/org/elasticsearch/index/IndexVersions.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ private static Version parseUnchecked(String version) {
141141
public static final IndexVersion RESCORE_PARAMS_ALLOW_ZERO_TO_QUANTIZED_VECTORS_BACKPORT_8_X = def(8_529_0_00, Version.LUCENE_9_12_1);
142142
public static final IndexVersion DEFAULT_OVERSAMPLE_VALUE_FOR_BBQ_BACKPORT_8_X = def(8_530_0_00, Version.LUCENE_9_12_1);
143143
public static final IndexVersion SEMANTIC_TEXT_DEFAULTS_TO_BBQ_BACKPORT_8_X = def(8_531_0_00, Version.LUCENE_9_12_1);
144+
public static final IndexVersion INDEX_INT_SORT_INT_TYPE_8_19 = def(8_532_0_00, Version.LUCENE_9_12_1);
144145
public static final IndexVersion UPGRADE_TO_LUCENE_10_0_0 = def(9_000_0_00, Version.LUCENE_10_0_0);
145146
public static final IndexVersion LOGSDB_DEFAULT_IGNORE_DYNAMIC_BEYOND_LIMIT = def(9_001_0_00, Version.LUCENE_10_0_0);
146147
public static final IndexVersion TIME_BASED_K_ORDERED_DOC_ID = def(9_002_0_00, Version.LUCENE_10_0_0);

server/src/main/java/org/elasticsearch/index/fielddata/IndexNumericFieldData.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
import java.io.IOException;
3535
import java.util.function.LongUnaryOperator;
3636

37+
import static org.elasticsearch.index.IndexVersions.UPGRADE_TO_LUCENE_10_0_0;
38+
3739
/**
3840
* Base class for numeric field data.
3941
*/
@@ -144,12 +146,18 @@ public SortField sortField(
144146
boolean reverse
145147
) {
146148
SortField sortField = sortField(missingValue, sortMode, nested, reverse);
147-
if (indexCreatedVersion.onOrAfter(IndexVersions.INDEX_INT_SORT_INT_TYPE) || getNumericType().sortFieldType != SortField.Type.INT) {
149+
// we introduced INT sort type in 8.19 and from 9.1
150+
if (getNumericType().sortFieldType != SortField.Type.INT
151+
|| indexCreatedVersion.onOrAfter(IndexVersions.INDEX_INT_SORT_INT_TYPE)
152+
|| indexCreatedVersion.between(IndexVersions.INDEX_INT_SORT_INT_TYPE_8_19, UPGRADE_TO_LUCENE_10_0_0)) {
148153
return sortField;
149154
}
150155
if ((sortField instanceof SortedNumericSortField) == false) {
151156
return sortField;
152157
}
158+
// if the index was created before 8.19, or in 9.0
159+
// we need to rewrite the sort field to use LONG sort type
160+
153161
// Rewrite INT sort to LONG sort.
154162
// Before indices used TYPE.LONG for index sorting on integer field,
155163
// and this is stored in their index writer config on disk and can't be modified.

0 commit comments

Comments
 (0)