Skip to content

Commit f2d1c71

Browse files
authored
Enable skippers for fields with index=false and doc_values=true (#138523)
This applies to boolean, date, ip, keyword and number-type fields. It can be disabled by setting the index.mapping.use_doc_value_skipper field to false
1 parent 637e498 commit f2d1c71

File tree

43 files changed

+274
-46
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+274
-46
lines changed

modules/data-streams/src/test/java/org/elasticsearch/datastreams/mapper/DataStreamTimestampFieldMapperTests.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,6 @@ public void testValidateInvalidFieldType() {
119119
);
120120
}
121121

122-
public void testValidateNotIndexed() {
123-
Exception e = expectThrows(IllegalArgumentException.class, () -> createMapperService(timestampMapping(true, b -> {
124-
b.startObject("@timestamp");
125-
b.field("type", "date");
126-
b.field("index", false);
127-
b.endObject();
128-
})));
129-
assertThat(e.getMessage(), equalTo("data stream timestamp field [@timestamp] is not indexed"));
130-
}
131-
132122
public void testValidateNotDocValues() {
133123
Exception e = expectThrows(IllegalArgumentException.class, () -> createMapperService(timestampMapping(true, b -> {
134124
b.startObject("@timestamp");

modules/legacy-geo/src/test/java/org/elasticsearch/legacygeo/mapper/LegacyGeoShapeFieldMapperTests.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,4 +671,9 @@ protected IngestScriptSupport ingestScriptSupport() {
671671
protected List<SortShortcutSupport> getSortShortcutSupport() {
672672
return List.of();
673673
}
674+
675+
@Override
676+
protected boolean supportsDocValuesSkippers() {
677+
return false;
678+
}
674679
}

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,12 +193,23 @@ protected Parameter<?>[] getParameters() {
193193
return new Parameter<?>[] { indexed, hasDocValues, stored, ignoreMalformed, meta, scalingFactor, coerce, nullValue, metric };
194194
}
195195

196+
private IndexType indexType() {
197+
if (indexed.getValue()) {
198+
return IndexType.points(true, hasDocValues.getValue());
199+
}
200+
if (hasDocValues.getValue()
201+
&& indexSettings.getIndexVersionCreated().onOrAfter(IndexVersions.STANDARD_INDEXES_USE_SKIPPERS)
202+
&& indexSettings.useDocValuesSkipper()) {
203+
return IndexType.skippers();
204+
}
205+
return IndexType.points(false, hasDocValues.getValue());
206+
}
207+
196208
@Override
197209
public ScaledFloatFieldMapper build(MapperBuilderContext context) {
198-
IndexType indexType = IndexType.points(indexed.get(), hasDocValues.get());
199210
ScaledFloatFieldType type = new ScaledFloatFieldType(
200211
context.buildFullName(leafName()),
201-
indexType,
212+
indexType(),
202213
stored.getValue(),
203214
meta.getValue(),
204215
scalingFactor.getValue(),

modules/mapper-extras/src/test/java/org/elasticsearch/index/mapper/extras/MatchOnlyTextFieldMapperTests.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,4 +390,9 @@ public void testLoadSyntheticSourceFromStringOrBytesRef() throws IOException {
390390
protected List<SortShortcutSupport> getSortShortcutSupport() {
391391
return List.of();
392392
}
393+
394+
@Override
395+
protected boolean supportsDocValuesSkippers() {
396+
return false;
397+
}
393398
}

modules/mapper-extras/src/test/java/org/elasticsearch/index/mapper/extras/RankFeatureFieldMapperTests.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,4 +220,9 @@ protected IngestScriptSupport ingestScriptSupport() {
220220
protected List<SortShortcutSupport> getSortShortcutSupport() {
221221
return List.of();
222222
}
223+
224+
@Override
225+
protected boolean supportsDocValuesSkippers() {
226+
return false;
227+
}
223228
}

modules/mapper-extras/src/test/java/org/elasticsearch/index/mapper/extras/RankFeaturesFieldMapperTests.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,4 +214,9 @@ protected IngestScriptSupport ingestScriptSupport() {
214214
protected List<SortShortcutSupport> getSortShortcutSupport() {
215215
return List.of();
216216
}
217+
218+
@Override
219+
protected boolean supportsDocValuesSkippers() {
220+
return false;
221+
}
217222
}

modules/mapper-extras/src/test/java/org/elasticsearch/index/mapper/extras/SearchAsYouTypeFieldMapperTests.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,4 +882,9 @@ protected IngestScriptSupport ingestScriptSupport() {
882882
protected List<SortShortcutSupport> getSortShortcutSupport() {
883883
return List.of();
884884
}
885+
886+
@Override
887+
protected boolean supportsDocValuesSkippers() {
888+
return false;
889+
}
885890
}

modules/mapper-extras/src/test/java/org/elasticsearch/index/mapper/extras/TokenCountFieldMapperTests.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,4 +269,9 @@ public void testAggregationsDocValuesDisabled() throws IOException {
269269
protected List<SortShortcutSupport> getSortShortcutSupport() {
270270
return List.of(new SortShortcutSupport(this::minimalMapping, this::writeField, true));
271271
}
272+
273+
@Override
274+
protected boolean supportsDocValuesSkippers() {
275+
return false;
276+
}
272277
}

plugins/analysis-icu/src/test/java/org/elasticsearch/plugin/analysis/icu/ICUCollationKeywordFieldMapperTests.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,4 +323,9 @@ protected IngestScriptSupport ingestScriptSupport() {
323323
protected List<SortShortcutSupport> getSortShortcutSupport() {
324324
return List.of(new SortShortcutSupport(this::minimalMapping, this::writeField, true));
325325
}
326+
327+
@Override
328+
protected boolean supportsDocValuesSkippers() {
329+
return false;
330+
}
326331
}

plugins/mapper-annotated-text/src/test/java/org/elasticsearch/index/mapper/annotatedtext/AnnotatedTextFieldMapperTests.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,4 +709,9 @@ protected IngestScriptSupport ingestScriptSupport() {
709709
protected List<SortShortcutSupport> getSortShortcutSupport() {
710710
return List.of();
711711
}
712+
713+
@Override
714+
protected boolean supportsDocValuesSkippers() {
715+
return false;
716+
}
712717
}

0 commit comments

Comments
 (0)