Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public class SmokeTestMultiNodeClientYamlTestSuiteIT extends ESClientYamlSuiteTe
.feature(FeatureFlag.TIME_SERIES_MODE)
.feature(FeatureFlag.SUB_OBJECTS_AUTO_ENABLED)
.feature(FeatureFlag.DOC_VALUES_SKIPPER)
.feature(FeatureFlag.USE_LUCENE101_POSTINGS_FORMAT)
.build();

public SmokeTestMultiNodeClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public class ClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase {
.feature(FeatureFlag.TIME_SERIES_MODE)
.feature(FeatureFlag.SUB_OBJECTS_AUTO_ENABLED)
.feature(FeatureFlag.DOC_VALUES_SKIPPER)
.feature(FeatureFlag.USE_LUCENE101_POSTINGS_FORMAT)
.build();

public ClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@
import org.apache.lucene.codecs.DocValuesFormat;
import org.apache.lucene.codecs.KnnVectorsFormat;
import org.apache.lucene.codecs.PostingsFormat;
import org.apache.lucene.codecs.lucene101.Lucene101PostingsFormat;
import org.apache.lucene.codecs.lucene90.Lucene90DocValuesFormat;
import org.apache.lucene.codecs.lucene99.Lucene99HnswVectorsFormat;
import org.elasticsearch.common.util.BigArrays;
import org.elasticsearch.common.util.FeatureFlag;
import org.elasticsearch.index.IndexMode;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.IndexVersions;
import org.elasticsearch.index.codec.bloomfilter.ES87BloomFilterPostingsFormat;
import org.elasticsearch.index.codec.postings.ES812PostingsFormat;
import org.elasticsearch.index.codec.tsdb.es819.ES819TSDBDocValuesFormat;
Expand All @@ -34,33 +31,19 @@
* vectors.
*/
public class PerFieldFormatSupplier {
public static final FeatureFlag USE_LUCENE101_POSTINGS_FORMAT = new FeatureFlag("use_lucene101_postings_format");

private static final DocValuesFormat docValuesFormat = new Lucene90DocValuesFormat();
private static final KnnVectorsFormat knnVectorsFormat = new Lucene99HnswVectorsFormat();
private static final ES819TSDBDocValuesFormat tsdbDocValuesFormat = new ES819TSDBDocValuesFormat();
private static final ES812PostingsFormat es812PostingsFormat = new ES812PostingsFormat();
private static final Lucene101PostingsFormat lucene101PostingsFormat = new Lucene101PostingsFormat();
private static final PostingsFormat completionPostingsFormat = PostingsFormat.forName("Completion101");

private final ES87BloomFilterPostingsFormat bloomFilterPostingsFormat;
private final MapperService mapperService;

private final PostingsFormat defaultPostingsFormat;

public PerFieldFormatSupplier(MapperService mapperService, BigArrays bigArrays) {
this.mapperService = mapperService;
this.bloomFilterPostingsFormat = new ES87BloomFilterPostingsFormat(bigArrays, this::internalGetPostingsFormatForField);

if (mapperService != null
&& USE_LUCENE101_POSTINGS_FORMAT.isEnabled()
&& mapperService.getIndexSettings().getIndexVersionCreated().onOrAfter(IndexVersions.USE_LUCENE101_POSTINGS_FORMAT)
&& mapperService.getIndexSettings().getMode() == IndexMode.STANDARD) {
defaultPostingsFormat = lucene101PostingsFormat;
} else {
// our own posting format using PFOR
defaultPostingsFormat = es812PostingsFormat;
}
}

public PostingsFormat getPostingsFormatForField(String field) {
Expand All @@ -77,8 +60,8 @@ private PostingsFormat internalGetPostingsFormatForField(String field) {
return completionPostingsFormat;
}
}

return defaultPostingsFormat;
// return our own posting format using PFOR
return es812PostingsFormat;
}

boolean useBloomFilter(String field) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

package org.elasticsearch.index.codec;

import org.apache.lucene.codecs.PostingsFormat;
import org.apache.lucene.codecs.lucene101.Lucene101PostingsFormat;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.common.compress.CompressedXContent;
import org.elasticsearch.common.settings.Settings;
Expand Down Expand Up @@ -88,15 +86,11 @@ public class PerFieldMapperCodecTests extends ESTestCase {
""";

public void testUseBloomFilter() throws IOException {
boolean timeSeries = randomBoolean();
PerFieldFormatSupplier perFieldMapperCodec = createFormatSupplier(false, timeSeries, false);
PerFieldFormatSupplier perFieldMapperCodec = createFormatSupplier(false, randomBoolean(), false);
assertThat(perFieldMapperCodec.useBloomFilter("_id"), is(true));
assertThat(perFieldMapperCodec.getPostingsFormatForField("_id"), instanceOf(ES87BloomFilterPostingsFormat.class));
assertThat(perFieldMapperCodec.useBloomFilter("another_field"), is(false));

Class<? extends PostingsFormat> expectedPostingsFormat = PerFieldFormatSupplier.USE_LUCENE101_POSTINGS_FORMAT.isEnabled()
&& timeSeries == false ? Lucene101PostingsFormat.class : ES812PostingsFormat.class;
assertThat(perFieldMapperCodec.getPostingsFormatForField("another_field"), instanceOf(expectedPostingsFormat));
assertThat(perFieldMapperCodec.getPostingsFormatForField("another_field"), instanceOf(ES812PostingsFormat.class));
}

public void testUseBloomFilterWithTimestampFieldEnabled() throws IOException {
Expand All @@ -110,10 +104,7 @@ public void testUseBloomFilterWithTimestampFieldEnabled() throws IOException {
public void testUseBloomFilterWithTimestampFieldEnabled_noTimeSeriesMode() throws IOException {
PerFieldFormatSupplier perFieldMapperCodec = createFormatSupplier(true, false, false);
assertThat(perFieldMapperCodec.useBloomFilter("_id"), is(false));
Class<? extends PostingsFormat> expectedPostingsFormat = PerFieldFormatSupplier.USE_LUCENE101_POSTINGS_FORMAT.isEnabled()
? Lucene101PostingsFormat.class
: ES812PostingsFormat.class;
assertThat(perFieldMapperCodec.getPostingsFormatForField("_id"), instanceOf(expectedPostingsFormat));
assertThat(perFieldMapperCodec.getPostingsFormatForField("_id"), instanceOf(ES812PostingsFormat.class));
}

public void testUseBloomFilterWithTimestampFieldEnabled_disableBloomFilter() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
public enum FeatureFlag {
TIME_SERIES_MODE("es.index_mode_feature_flag_registered=true", Version.fromString("8.0.0"), null),
SUB_OBJECTS_AUTO_ENABLED("es.sub_objects_auto_feature_flag_enabled=true", Version.fromString("8.16.0"), null),
DOC_VALUES_SKIPPER("es.doc_values_skipper_feature_flag_enabled=true", Version.fromString("8.18.1"), null),
USE_LUCENE101_POSTINGS_FORMAT("es.use_lucene101_postings_format_feature_flag_enabled=true", Version.fromString("9.1.0"), null);
DOC_VALUES_SKIPPER("es.doc_values_skipper_feature_flag_enabled=true", Version.fromString("8.18.1"), null);

public final String systemProperty;
public final Version from;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public class LogsdbTestSuiteIT extends ESClientYamlSuiteTestCase {
.setting("xpack.security.enabled", "false")
.setting("xpack.license.self_generated.type", "trial")
.feature(FeatureFlag.DOC_VALUES_SKIPPER)
.feature(FeatureFlag.USE_LUCENE101_POSTINGS_FORMAT)
.build();

public LogsdbTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public class CoreWithSecurityClientYamlTestSuiteIT extends ESClientYamlSuiteTest
.feature(FeatureFlag.TIME_SERIES_MODE)
.feature(FeatureFlag.SUB_OBJECTS_AUTO_ENABLED)
.feature(FeatureFlag.DOC_VALUES_SKIPPER)
.feature(FeatureFlag.USE_LUCENE101_POSTINGS_FORMAT)
.build();

public CoreWithSecurityClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) {
Expand Down