|
15 | 15 | import org.apache.lucene.codecs.lucene90.Lucene90DocValuesFormat; |
16 | 16 | import org.apache.lucene.codecs.lucene99.Lucene99HnswVectorsFormat; |
17 | 17 | import org.elasticsearch.common.util.BigArrays; |
| 18 | +import org.elasticsearch.common.util.FeatureFlag; |
18 | 19 | import org.elasticsearch.index.IndexMode; |
19 | 20 | import org.elasticsearch.index.IndexSettings; |
20 | 21 | import org.elasticsearch.index.IndexVersions; |
|
25 | 26 | import org.elasticsearch.index.mapper.IdFieldMapper; |
26 | 27 | import org.elasticsearch.index.mapper.Mapper; |
27 | 28 | import org.elasticsearch.index.mapper.MapperService; |
| 29 | +import org.elasticsearch.index.mapper.SeqNoFieldMapper; |
28 | 30 | import org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper; |
29 | 31 |
|
30 | 32 | /** |
|
33 | 35 | */ |
34 | 36 | public class PerFieldFormatSupplier { |
35 | 37 |
|
| 38 | + private static final FeatureFlag SEQNO_FIELD_USE_TSDB_DOC_VALUES_FORMAT = new FeatureFlag("seqno_field_use_tsdb_doc_values_format"); |
| 39 | + |
36 | 40 | private static final DocValuesFormat docValuesFormat = new Lucene90DocValuesFormat(); |
37 | 41 | private static final KnnVectorsFormat knnVectorsFormat = new Lucene99HnswVectorsFormat(); |
38 | 42 | private static final ES819TSDBDocValuesFormat tsdbDocValuesFormat = new ES819TSDBDocValuesFormat(); |
@@ -122,9 +126,13 @@ boolean useTSDBDocValuesFormat(final String field) { |
122 | 126 | } |
123 | 127 |
|
124 | 128 | private boolean excludeFields(String fieldName) { |
| 129 | + // TODO: should we just allow all fields to use tsdb doc values codec? |
125 | 130 | // Avoid using tsdb codec for fields like _seq_no, _primary_term. |
126 | 131 | // But _tsid and _ts_routing_hash should always use the tsdb codec. |
127 | | - return fieldName.startsWith("_") && fieldName.equals("_tsid") == false && fieldName.equals("_ts_routing_hash") == false; |
| 132 | + return fieldName.startsWith("_") |
| 133 | + && fieldName.equals("_tsid") == false |
| 134 | + && fieldName.equals("_ts_routing_hash") == false |
| 135 | + && (SEQNO_FIELD_USE_TSDB_DOC_VALUES_FORMAT.isEnabled() && fieldName.equals(SeqNoFieldMapper.NAME) == false); |
128 | 136 | } |
129 | 137 |
|
130 | 138 | private boolean isTimeSeriesModeIndex() { |
|
0 commit comments