Skip to content
Merged
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 @@ -28,6 +28,8 @@
*/
public class Elasticsearch900Lucene101Codec extends CodecService.DeduplicateFieldInfosCodec {

static final PostingsFormat DEFAULT_POSTINGS_FORMAT = new Lucene101PostingsFormat();

private final StoredFieldsFormat storedFieldsFormat;

private final PostingsFormat defaultPostingsFormat;
Expand Down Expand Up @@ -66,7 +68,7 @@ public Elasticsearch900Lucene101Codec() {
public Elasticsearch900Lucene101Codec(Zstd814StoredFieldsFormat.Mode mode) {
super("Elasticsearch900Lucene101", new Lucene101Codec());
this.storedFieldsFormat = mode.getFormat();
this.defaultPostingsFormat = new Lucene101PostingsFormat();
this.defaultPostingsFormat = DEFAULT_POSTINGS_FORMAT;
this.defaultDVFormat = new Lucene90DocValuesFormat();
this.defaultKnnVectorsFormat = new Lucene99HnswVectorsFormat();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
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;
Expand All @@ -34,13 +33,12 @@
* vectors.
*/
public class PerFieldFormatSupplier {
public static final FeatureFlag USE_LUCENE101_POSTINGS_FORMAT = new FeatureFlag("use_lucene101_postings_format");
public static final FeatureFlag USE_DEFAULT_LUCENE_POSTINGS_FORMAT = new FeatureFlag("use_default_lucene_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;
Expand All @@ -53,10 +51,10 @@ public PerFieldFormatSupplier(MapperService mapperService, BigArrays bigArrays)
this.bloomFilterPostingsFormat = new ES87BloomFilterPostingsFormat(bigArrays, this::internalGetPostingsFormatForField);

if (mapperService != null
&& USE_LUCENE101_POSTINGS_FORMAT.isEnabled()
&& USE_DEFAULT_LUCENE_POSTINGS_FORMAT.isEnabled()
&& mapperService.getIndexSettings().getIndexVersionCreated().onOrAfter(IndexVersions.USE_LUCENE101_POSTINGS_FORMAT)
&& mapperService.getIndexSettings().getMode() == IndexMode.STANDARD) {
defaultPostingsFormat = lucene101PostingsFormat;
defaultPostingsFormat = Elasticsearch900Lucene101Codec.DEFAULT_POSTINGS_FORMAT;
} else {
// our own posting format using PFOR
defaultPostingsFormat = es812PostingsFormat;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void testUseBloomFilter() throws IOException {
assertThat(perFieldMapperCodec.getPostingsFormatForField("_id"), instanceOf(ES87BloomFilterPostingsFormat.class));
assertThat(perFieldMapperCodec.useBloomFilter("another_field"), is(false));

Class<? extends PostingsFormat> expectedPostingsFormat = PerFieldFormatSupplier.USE_LUCENE101_POSTINGS_FORMAT.isEnabled()
Class<? extends PostingsFormat> expectedPostingsFormat = PerFieldFormatSupplier.USE_DEFAULT_LUCENE_POSTINGS_FORMAT.isEnabled()
&& timeSeries == false ? Lucene101PostingsFormat.class : ES812PostingsFormat.class;
assertThat(perFieldMapperCodec.getPostingsFormatForField("another_field"), instanceOf(expectedPostingsFormat));
}
Expand All @@ -110,7 +110,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()
Class<? extends PostingsFormat> expectedPostingsFormat = PerFieldFormatSupplier.USE_DEFAULT_LUCENE_POSTINGS_FORMAT.isEnabled()
? Lucene101PostingsFormat.class
: ES812PostingsFormat.class;
assertThat(perFieldMapperCodec.getPostingsFormatForField("_id"), instanceOf(expectedPostingsFormat));
Expand Down