Skip to content

Commit f352d41

Browse files
committed
Update
1 parent f8e03c4 commit f352d41

File tree

10 files changed

+19
-18
lines changed

10 files changed

+19
-18
lines changed

modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/extras/ScaledFloatFieldMapper.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ public BlockLoader blockLoader(BlockLoaderContext blContext) {
320320
// Counters are not supported by ESQL so we load them in null
321321
return BlockLoader.CONSTANT_NULLS;
322322
}
323-
if (hasDocValues() && (blContext.fieldExtractPreference() != FieldExtractPreference.PREFER_STORED || isSyntheticSource)) {
323+
if (hasDocValues() && (blContext.fieldExtractPreference() != FieldExtractPreference.STORED || isSyntheticSource)) {
324324
return new BlockDocValuesReader.DoublesBlockLoader(name(), l -> l / scalingFactor);
325325
}
326326
if (isSyntheticSource) {
@@ -334,6 +334,7 @@ public Builder builder(BlockFactory factory, int expectedCount) {
334334

335335
ValueFetcher valueFetcher = sourceValueFetcher(blContext.sourcePaths(name()));
336336
BlockSourceReader.LeafIteratorLookup lookup = hasDocValues() == false && (isStored() || isIndexed())
337+
// We only write the field names field if there aren't doc values or norms
337338
? BlockSourceReader.lookupFromFieldNames(blContext.fieldNames(), name())
338339
: BlockSourceReader.lookupMatchingAll();
339340
return new BlockSourceReader.DoublesBlockLoader(valueFetcher, lookup);

server/src/main/java/org/elasticsearch/index/mapper/KeywordFieldMapper.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ NamedAnalyzer normalizer() {
748748

749749
@Override
750750
public BlockLoader blockLoader(BlockLoaderContext blContext) {
751-
if (hasDocValues() && (blContext.fieldExtractPreference() != FieldExtractPreference.PREFER_STORED || isSyntheticSource)) {
751+
if (hasDocValues() && (blContext.fieldExtractPreference() != FieldExtractPreference.STORED || isSyntheticSource)) {
752752
return new BlockDocValuesReader.BytesRefsFromOrdsBlockLoader(name());
753753
}
754754
if (isStored()) {
@@ -807,6 +807,7 @@ private BlockSourceReader.LeafIteratorLookup sourceBlockLoaderLookup(BlockLoader
807807
return BlockSourceReader.lookupFromNorms(name());
808808
}
809809
if (hasDocValues() == false && (isIndexed() || isStored())) {
810+
// We only write the field names field if there aren't doc values or norms
810811
return BlockSourceReader.lookupFromFieldNames(blContext.fieldNames(), name());
811812
}
812813
return BlockSourceReader.lookupMatchingAll();

server/src/main/java/org/elasticsearch/index/mapper/MappedFieldType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ public enum FieldExtractPreference {
698698
* loading many fields. The {@link MappedFieldType} can chose a different
699699
* method to load the field if it needs to.
700700
*/
701-
PREFER_STORED;
701+
STORED;
702702
}
703703

704704
/**

server/src/main/java/org/elasticsearch/index/mapper/NumberFieldMapper.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1912,7 +1912,7 @@ public Function<byte[], Number> pointReaderIfPossible() {
19121912

19131913
@Override
19141914
public BlockLoader blockLoader(BlockLoaderContext blContext) {
1915-
if (hasDocValues() && (blContext.fieldExtractPreference() != FieldExtractPreference.PREFER_STORED || isSyntheticSource)) {
1915+
if (hasDocValues() && (blContext.fieldExtractPreference() != FieldExtractPreference.STORED || isSyntheticSource)) {
19161916
return type.blockLoaderFromDocValues(name());
19171917
}
19181918

@@ -1921,6 +1921,7 @@ public BlockLoader blockLoader(BlockLoaderContext blContext) {
19211921
}
19221922

19231923
BlockSourceReader.LeafIteratorLookup lookup = hasDocValues() == false && (isStored() || isIndexed())
1924+
// We only write the field names field if there aren't doc values or norms
19241925
? BlockSourceReader.lookupFromFieldNames(blContext.fieldNames(), name())
19251926
: BlockSourceReader.lookupMatchingAll();
19261927
return type.blockLoaderFromSource(sourceValueFetcher(blContext.sourcePaths(name())), lookup);

test/framework/src/main/java/org/elasticsearch/index/mapper/BlockLoaderTestCase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
public abstract class BlockLoaderTestCase extends MapperServiceTestCase {
4545
private static final MappedFieldType.FieldExtractPreference[] PREFERENCES = new MappedFieldType.FieldExtractPreference[] {
4646
MappedFieldType.FieldExtractPreference.NONE,
47-
MappedFieldType.FieldExtractPreference.PREFER_STORED };
47+
MappedFieldType.FieldExtractPreference.STORED };
4848

4949
@ParametersFactory(argumentFormatting = "preference=%s")
5050
public static List<Object[]> args() {

x-pack/plugin/esql/qa/server/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/mixed/FieldExtractorIT.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ protected String getTestRestCluster() {
3737
@Override
3838
protected Matcher<Integer> pidMatcher() {
3939
// TODO these should all always return null because the parent is nested
40-
return preference == MappedFieldType.FieldExtractPreference.PREFER_STORED
41-
? anyOf(equalTo(111), nullValue())
42-
: nullValue(Integer.class);
40+
return preference == MappedFieldType.FieldExtractPreference.STORED ? anyOf(equalTo(111), nullValue()) : nullValue(Integer.class);
4341
}
4442

4543
}

x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/FieldExtractorTestCase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public static List<Object[]> args() throws Exception {
7171
return List.of(
7272
new Object[] { null },
7373
new Object[] { MappedFieldType.FieldExtractPreference.NONE },
74-
new Object[] { MappedFieldType.FieldExtractPreference.PREFER_STORED }
74+
new Object[] { MappedFieldType.FieldExtractPreference.STORED }
7575
);
7676
}
7777

@@ -1353,7 +1353,7 @@ public void testOneNestedField_AndSameNameSupportedField_TwoIndices() throws IOE
13531353

13541354
protected Matcher<Integer> pidMatcher() {
13551355
// TODO these should all always return null because the parent is nested
1356-
return preference == MappedFieldType.FieldExtractPreference.PREFER_STORED ? equalTo(111) : nullValue(Integer.class);
1356+
return preference == MappedFieldType.FieldExtractPreference.STORED ? equalTo(111) : nullValue(Integer.class);
13571357
}
13581358

13591359
private void assumeIndexResolverNestedFieldsNameClashFixed() throws IOException {

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SpatialCentroid.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,11 @@ public AggregatorFunctionSupplier supplier() {
104104
return switch (type) {
105105
case DataType.GEO_POINT -> switch (fieldExtractPreference) {
106106
case DOC_VALUES -> new SpatialCentroidGeoPointDocValuesAggregatorFunctionSupplier();
107-
case NONE, EXTRACT_SPATIAL_BOUNDS, PREFER_STORED -> new SpatialCentroidGeoPointSourceValuesAggregatorFunctionSupplier();
107+
case NONE, EXTRACT_SPATIAL_BOUNDS, STORED -> new SpatialCentroidGeoPointSourceValuesAggregatorFunctionSupplier();
108108
};
109109
case DataType.CARTESIAN_POINT -> switch (fieldExtractPreference) {
110110
case DOC_VALUES -> new SpatialCentroidCartesianPointDocValuesAggregatorFunctionSupplier();
111-
case NONE, EXTRACT_SPATIAL_BOUNDS, PREFER_STORED ->
112-
new SpatialCentroidCartesianPointSourceValuesAggregatorFunctionSupplier();
111+
case NONE, EXTRACT_SPATIAL_BOUNDS, STORED -> new SpatialCentroidCartesianPointSourceValuesAggregatorFunctionSupplier();
113112
};
114113
default -> throw EsqlIllegalArgumentException.illegalDataType(type);
115114
};

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SpatialExtent.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,20 +108,20 @@ public AggregatorFunctionSupplier supplier() {
108108
return switch (type) {
109109
case DataType.GEO_POINT -> switch (fieldExtractPreference) {
110110
case DOC_VALUES -> new SpatialExtentGeoPointDocValuesAggregatorFunctionSupplier();
111-
case NONE, EXTRACT_SPATIAL_BOUNDS, PREFER_STORED -> new SpatialExtentGeoPointSourceValuesAggregatorFunctionSupplier();
111+
case NONE, EXTRACT_SPATIAL_BOUNDS, STORED -> new SpatialExtentGeoPointSourceValuesAggregatorFunctionSupplier();
112112
};
113113
case DataType.CARTESIAN_POINT -> switch (fieldExtractPreference) {
114114
case DOC_VALUES -> new SpatialExtentCartesianPointDocValuesAggregatorFunctionSupplier();
115-
case NONE, EXTRACT_SPATIAL_BOUNDS, PREFER_STORED -> new SpatialExtentCartesianPointSourceValuesAggregatorFunctionSupplier();
115+
case NONE, EXTRACT_SPATIAL_BOUNDS, STORED -> new SpatialExtentCartesianPointSourceValuesAggregatorFunctionSupplier();
116116
};
117117
case DataType.GEO_SHAPE -> switch (fieldExtractPreference) {
118118
case EXTRACT_SPATIAL_BOUNDS -> new SpatialExtentGeoShapeDocValuesAggregatorFunctionSupplier();
119-
case NONE, PREFER_STORED -> new SpatialExtentGeoShapeSourceValuesAggregatorFunctionSupplier();
119+
case NONE, STORED -> new SpatialExtentGeoShapeSourceValuesAggregatorFunctionSupplier();
120120
case DOC_VALUES -> throw new EsqlIllegalArgumentException("Illegal field extract preference: " + fieldExtractPreference);
121121
};
122122
case DataType.CARTESIAN_SHAPE -> switch (fieldExtractPreference) {
123123
case EXTRACT_SPATIAL_BOUNDS -> new SpatialExtentCartesianShapeDocValuesAggregatorFunctionSupplier();
124-
case NONE, PREFER_STORED -> new SpatialExtentCartesianShapeSourceValuesAggregatorFunctionSupplier();
124+
case NONE, STORED -> new SpatialExtentCartesianShapeSourceValuesAggregatorFunctionSupplier();
125125
case DOC_VALUES -> throw new EsqlIllegalArgumentException("Illegal field extract preference: " + fieldExtractPreference);
126126
};
127127
default -> throw EsqlIllegalArgumentException.illegalDataType(type);

x-pack/plugin/mapper-unsigned-long/src/main/java/org/elasticsearch/xpack/unsignedlong/UnsignedLongFieldMapper.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ public BlockLoader blockLoader(BlockLoaderContext blContext) {
329329
// Counters are not supported by ESQL so we load them in null
330330
return BlockLoader.CONSTANT_NULLS;
331331
}
332-
if (hasDocValues() && (blContext.fieldExtractPreference() != FieldExtractPreference.PREFER_STORED || isSyntheticSource)) {
332+
if (hasDocValues() && (blContext.fieldExtractPreference() != FieldExtractPreference.STORED || isSyntheticSource)) {
333333
return new BlockDocValuesReader.LongsBlockLoader(name());
334334
}
335335
if (isSyntheticSource) {
@@ -355,6 +355,7 @@ protected Object parseSourceValue(Object value) {
355355
}
356356
};
357357
BlockSourceReader.LeafIteratorLookup lookup = hasDocValues() == false && (isStored() || isIndexed())
358+
// We only write the field names field if there aren't doc values or norms
358359
? BlockSourceReader.lookupFromFieldNames(blContext.fieldNames(), name())
359360
: BlockSourceReader.lookupMatchingAll();
360361
return new BlockSourceReader.LongsBlockLoader(valueFetcher, lookup);

0 commit comments

Comments
 (0)