Skip to content

Commit 05fd027

Browse files
committed
Remove use_default_lucene_postings_format feature flag and
let the IndexMode decide whether to default lucene postings instead of checking for standard index mode. The `Lucene101PostingsFormat` is now used for a while behind a feature flag. Regressions were found by were fixed via apache/lucene#14511. The `Lucene101PostingsFormat` is now a better trade off when the index mode is standard.
1 parent 6a4a285 commit 05fd027

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ public void validateSourceFieldMapper(SourceFieldMapper sourceFieldMapper) {}
129129
public SourceFieldMapper.Mode defaultSourceMode() {
130130
return SourceFieldMapper.Mode.STORED;
131131
}
132+
133+
@Override
134+
public boolean useDefaultPostingsFormat() {
135+
return true;
136+
}
132137
},
133138
TIME_SERIES("time_series") {
134139
@Override
@@ -552,6 +557,13 @@ public String getDefaultCodec() {
552557
return CodecService.DEFAULT_CODEC;
553558
}
554559

560+
/**
561+
* Whether the default posting format (for inverted indices) from Lucene should be used.
562+
*/
563+
public boolean useDefaultPostingsFormat() {
564+
return false;
565+
}
566+
555567
/**
556568
* Parse a string into an {@link IndexMode}.
557569
*/

server/src/main/java/org/elasticsearch/index/codec/PerFieldFormatSupplier.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import org.apache.lucene.codecs.lucene90.Lucene90DocValuesFormat;
1616
import org.apache.lucene.codecs.lucene99.Lucene99HnswVectorsFormat;
1717
import org.elasticsearch.common.util.BigArrays;
18-
import org.elasticsearch.common.util.FeatureFlag;
1918
import org.elasticsearch.index.IndexMode;
2019
import org.elasticsearch.index.IndexSettings;
2120
import org.elasticsearch.index.IndexVersions;
@@ -33,7 +32,6 @@
3332
* vectors.
3433
*/
3534
public class PerFieldFormatSupplier {
36-
public static final FeatureFlag USE_DEFAULT_LUCENE_POSTINGS_FORMAT = new FeatureFlag("use_default_lucene_postings_format");
3735

3836
private static final DocValuesFormat docValuesFormat = new Lucene90DocValuesFormat();
3937
private static final KnnVectorsFormat knnVectorsFormat = new Lucene99HnswVectorsFormat();
@@ -51,9 +49,8 @@ public PerFieldFormatSupplier(MapperService mapperService, BigArrays bigArrays)
5149
this.bloomFilterPostingsFormat = new ES87BloomFilterPostingsFormat(bigArrays, this::internalGetPostingsFormatForField);
5250

5351
if (mapperService != null
54-
&& USE_DEFAULT_LUCENE_POSTINGS_FORMAT.isEnabled()
5552
&& mapperService.getIndexSettings().getIndexVersionCreated().onOrAfter(IndexVersions.USE_LUCENE101_POSTINGS_FORMAT)
56-
&& mapperService.getIndexSettings().getMode() == IndexMode.STANDARD) {
53+
&& mapperService.getIndexSettings().getMode().useDefaultPostingsFormat()) {
5754
defaultPostingsFormat = Elasticsearch900Lucene101Codec.DEFAULT_POSTINGS_FORMAT;
5855
} else {
5956
// our own posting format using PFOR

server/src/test/java/org/elasticsearch/index/codec/PerFieldMapperCodecTests.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ public void testUseBloomFilter() throws IOException {
9494
assertThat(perFieldMapperCodec.getPostingsFormatForField("_id"), instanceOf(ES87BloomFilterPostingsFormat.class));
9595
assertThat(perFieldMapperCodec.useBloomFilter("another_field"), is(false));
9696

97-
Class<? extends PostingsFormat> expectedPostingsFormat = PerFieldFormatSupplier.USE_DEFAULT_LUCENE_POSTINGS_FORMAT.isEnabled()
98-
&& timeSeries == false ? Lucene101PostingsFormat.class : ES812PostingsFormat.class;
97+
Class<? extends PostingsFormat> expectedPostingsFormat = timeSeries ? ES812PostingsFormat.class : Lucene101PostingsFormat.class;
9998
assertThat(perFieldMapperCodec.getPostingsFormatForField("another_field"), instanceOf(expectedPostingsFormat));
10099
}
101100

@@ -110,10 +109,7 @@ public void testUseBloomFilterWithTimestampFieldEnabled() throws IOException {
110109
public void testUseBloomFilterWithTimestampFieldEnabled_noTimeSeriesMode() throws IOException {
111110
PerFieldFormatSupplier perFieldMapperCodec = createFormatSupplier(true, false, false);
112111
assertThat(perFieldMapperCodec.useBloomFilter("_id"), is(false));
113-
Class<? extends PostingsFormat> expectedPostingsFormat = PerFieldFormatSupplier.USE_DEFAULT_LUCENE_POSTINGS_FORMAT.isEnabled()
114-
? Lucene101PostingsFormat.class
115-
: ES812PostingsFormat.class;
116-
assertThat(perFieldMapperCodec.getPostingsFormatForField("_id"), instanceOf(expectedPostingsFormat));
112+
assertThat(perFieldMapperCodec.getPostingsFormatForField("_id"), instanceOf(Lucene101PostingsFormat.class));
117113
}
118114

119115
public void testUseBloomFilterWithTimestampFieldEnabled_disableBloomFilter() throws IOException {

0 commit comments

Comments
 (0)