Skip to content

Commit

Permalink
Finxing broken UT (opensearch-project#10087)
Browse files Browse the repository at this point in the history
Signed-off-by: Gohel <gashutos@88665a2fc937.ant.amazon.com>
Co-authored-by: Gohel <gashutos@88665a2fc937.ant.amazon.com>
  • Loading branch information
gashutos and Gohel committed Sep 16, 2023
1 parent 5fdd418 commit d7aa6dd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 2 additions & 0 deletions server/src/main/java/org/opensearch/index/IndexService.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,10 @@ public IndexService(
if (indexSettings.getIndexSortConfig().hasIndexSort()) {
// we delay the actual creation of the sort order for this index because the mapping has not been merged yet.
// The sort order is validated right after the merge of the mapping later in the process.
boolean shouldWidenIndexSortType = this.indexSettings.shouldWidenIndexSortType();
this.indexSortSupplier = () -> indexSettings.getIndexSortConfig()
.buildIndexSort(
shouldWidenIndexSortType,
mapperService::fieldType,
(fieldType, searchLookup) -> indexFieldData.getForField(fieldType, indexFieldData.index().getName(), searchLookup)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ private static MultiValueMode parseMultiValueMode(String value) {

// visible for tests
final FieldSortSpec[] sortSpecs;
final boolean shouldWidenIndexSortType;

public IndexSortConfig(IndexSettings indexSettings) {
final Settings settings = indexSettings.getSettings();
Expand Down Expand Up @@ -183,7 +182,6 @@ public IndexSortConfig(IndexSettings indexSettings) {
sortSpecs[i].missingValue = missingValues.get(i);
}
}
this.shouldWidenIndexSortType = indexSettings.shouldWidenIndexSortType();
}

/**
Expand All @@ -202,6 +200,7 @@ public boolean hasPrimarySortOnField(String field) {
* or returns null if this index has no sort.
*/
public Sort buildIndexSort(
boolean shouldWidenIndexSortType,
Function<String, MappedFieldType> fieldTypeLookup,
BiFunction<MappedFieldType, Supplier<SearchLookup>, IndexFieldData<?>> fieldDataLookup
) {
Expand Down Expand Up @@ -232,7 +231,7 @@ public Sort buildIndexSort(
if (fieldData == null) {
throw new IllegalArgumentException("docvalues not found for index sort field:[" + sortSpec.field + "]");
}
if (this.shouldWidenIndexSortType == true) {
if (shouldWidenIndexSortType == true) {
sortFields[i] = fieldData.wideSortField(sortSpec.missingValue, mode, null, reverse);
} else {
sortFields[i] = fieldData.sortField(sortSpec.missingValue, mode, null, reverse);
Expand Down

0 comments on commit d7aa6dd

Please sign in to comment.