|
|
@@ -25,10 +25,6 @@ import org.elasticsearch.index.mapper.IdFieldMapper;
|
|
|
import org.elasticsearch.index.mapper.Mapper;
|
|
|
import org.elasticsearch.index.mapper.MapperService;
|
|
|
import org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper;
|
|
|
-import org.elasticsearch.internal.CompletionsPostingsFormatExtension;
|
|
|
-import org.elasticsearch.plugins.ExtensionLoader;
|
|
|
-
|
|
|
-import java.util.ServiceLoader;
|
|
|
|
|
|
/**
|
|
|
* Class that encapsulates the logic of figuring out the most appropriate file format for a given field, across postings, doc values and
|
|
|
@@ -40,6 +36,7 @@ public class PerFieldFormatSupplier {
|
|
|
private static final KnnVectorsFormat knnVectorsFormat = new Lucene99HnswVectorsFormat();
|
|
|
private static final ES87TSDBDocValuesFormat tsdbDocValuesFormat = new ES87TSDBDocValuesFormat();
|
|
|
private static final ES812PostingsFormat es812PostingsFormat = new ES812PostingsFormat();
|
|
|
+ private static final PostingsFormat completionPostingsFormat = PostingsFormat.forName("Completion101");
|
|
|
|
|
|
private final ES87BloomFilterPostingsFormat bloomFilterPostingsFormat;
|
|
|
private final MapperService mapperService;
|
|
|
@@ -60,26 +57,13 @@ public class PerFieldFormatSupplier {
|
|
|
if (mapperService != null) {
|
|
|
Mapper mapper = mapperService.mappingLookup().getMapper(field);
|
|
|
if (mapper instanceof CompletionFieldMapper) {
|
|
|
- return CompletionPostingsFormatHolder.POSTINGS_FORMAT;
|
|
|
+ return completionPostingsFormat;
|
|
|
}
|
|
|
}
|
|
|
// return our own posting format using PFOR
|
|
|
return es812PostingsFormat;
|
|
|
}
|
|
|
|
|
|
- private static class CompletionPostingsFormatHolder {
|
|
|
- private static final PostingsFormat POSTINGS_FORMAT = getCompletionPostingsFormat();
|
|
|
-
|
|
|
- private static PostingsFormat getCompletionPostingsFormat() {
|
|
|
- String defaultName = "Completion101"; // Caution: changing this name will result in exceptions if a field is created during a
|
|
|
- // rolling upgrade and the new codec (specified by the name) is not available on all nodes in the cluster.
|
|
|
- String codecName = ExtensionLoader.loadSingleton(ServiceLoader.load(CompletionsPostingsFormatExtension.class))
|
|
|
- .map(CompletionsPostingsFormatExtension::getFormatName)
|
|
|
- .orElse(defaultName);
|
|
|
- return PostingsFormat.forName(codecName);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
boolean useBloomFilter(String field) {
|
|
|
if (mapperService == null) {
|
|
|
return false;
|