2020import org .elasticsearch .index .IndexVersions ;
2121import org .elasticsearch .index .codec .bloomfilter .ES87BloomFilterPostingsFormat ;
2222import org .elasticsearch .index .codec .postings .ES812PostingsFormat ;
23+ import org .elasticsearch .index .codec .tsdb .ES87TSDBDocValuesFormat ;
2324import org .elasticsearch .index .codec .tsdb .es819 .ES819TSDBDocValuesFormat ;
2425import org .elasticsearch .index .mapper .CompletionFieldMapper ;
2526import org .elasticsearch .index .mapper .IdFieldMapper ;
@@ -35,14 +36,16 @@ public class PerFieldFormatSupplier {
3536
3637 private static final DocValuesFormat docValuesFormat = new Lucene90DocValuesFormat ();
3738 private static final KnnVectorsFormat knnVectorsFormat = new Lucene99HnswVectorsFormat ();
38- private static final ES819TSDBDocValuesFormat tsdbDocValuesFormat = new ES819TSDBDocValuesFormat ();
39+ private static final ES87TSDBDocValuesFormat es87TsdbDocValuesFormat = new ES87TSDBDocValuesFormat ();
40+ private static final ES819TSDBDocValuesFormat es819TsdbDocValuesFormat = new ES819TSDBDocValuesFormat ();
3941 private static final ES812PostingsFormat es812PostingsFormat = new ES812PostingsFormat ();
4042 private static final PostingsFormat completionPostingsFormat = PostingsFormat .forName ("Completion101" );
4143
4244 private final ES87BloomFilterPostingsFormat bloomFilterPostingsFormat ;
4345 private final MapperService mapperService ;
4446
4547 private final PostingsFormat defaultPostingsFormat ;
48+ private final DocValuesFormat defaultTsdbDocValuesFormat ;
4649
4750 public PerFieldFormatSupplier (MapperService mapperService , BigArrays bigArrays ) {
4851 this .mapperService = mapperService ;
@@ -56,6 +59,12 @@ public PerFieldFormatSupplier(MapperService mapperService, BigArrays bigArrays)
5659 // our own posting format using PFOR
5760 defaultPostingsFormat = es812PostingsFormat ;
5861 }
62+ if (mapperService != null
63+ && mapperService .getIndexSettings ().getIndexVersionCreated ().onOrAfter (IndexVersions .USE_819_TSDB_DOC_VALUES_FORMAT )) {
64+ defaultTsdbDocValuesFormat = es819TsdbDocValuesFormat ;
65+ } else {
66+ defaultTsdbDocValuesFormat = es87TsdbDocValuesFormat ;
67+ }
5968 }
6069
6170 public PostingsFormat getPostingsFormatForField (String field ) {
@@ -106,7 +115,7 @@ public KnnVectorsFormat getKnnVectorsFormatForField(String field) {
106115
107116 public DocValuesFormat getDocValuesFormatForField (String field ) {
108117 if (useTSDBDocValuesFormat (field )) {
109- return tsdbDocValuesFormat ;
118+ return defaultTsdbDocValuesFormat ;
110119 }
111120 return docValuesFormat ;
112121 }
0 commit comments