Skip to content

Commit 48e15a8

Browse files
committed
Restrict compression to keyword binary doc values
1 parent 57c2f24 commit 48e15a8

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

server/src/main/java/org/elasticsearch/index/codec/PerFieldFormatSupplier.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@
2020
import org.elasticsearch.index.IndexVersions;
2121
import org.elasticsearch.index.codec.bloomfilter.ES87BloomFilterPostingsFormat;
2222
import org.elasticsearch.index.codec.postings.ES812PostingsFormat;
23+
import org.elasticsearch.index.codec.tsdb.BinaryDVCompressionMode;
2324
import org.elasticsearch.index.codec.tsdb.es819.ES819TSDBDocValuesFormat;
2425
import org.elasticsearch.index.mapper.CompletionFieldMapper;
2526
import org.elasticsearch.index.mapper.IdFieldMapper;
27+
import org.elasticsearch.index.mapper.KeywordFieldMapper;
2628
import org.elasticsearch.index.mapper.Mapper;
2729
import org.elasticsearch.index.mapper.MapperService;
2830
import org.elasticsearch.index.mapper.SeqNoFieldMapper;
@@ -57,7 +59,8 @@ public class PerFieldFormatSupplier {
5759

5860
private static final DocValuesFormat docValuesFormat = new Lucene90DocValuesFormat();
5961
private static final KnnVectorsFormat knnVectorsFormat = new Lucene99HnswVectorsFormat();
60-
private static final ES819TSDBDocValuesFormat tsdbDocValuesFormat = new ES819TSDBDocValuesFormat();
62+
private static final ES819TSDBDocValuesFormat tsdbDocValuesFormat = new ES819TSDBDocValuesFormat(BinaryDVCompressionMode.NO_COMPRESS);
63+
private static final DocValuesFormat compressedBinaryDocValuesFormat = new ES819TSDBDocValuesFormat(BinaryDVCompressionMode.COMPRESSED_WITH_LZ4);
6164
private static final ES812PostingsFormat es812PostingsFormat = new ES812PostingsFormat();
6265
private static final PostingsFormat completionPostingsFormat = PostingsFormat.forName("Completion101");
6366

@@ -127,6 +130,13 @@ public KnnVectorsFormat getKnnVectorsFormatForField(String field) {
127130
}
128131

129132
public DocValuesFormat getDocValuesFormatForField(String field) {
133+
if (mapperService != null) {
134+
Mapper mapper = mapperService.mappingLookup().getMapper(field);
135+
if (mapper != null && KeywordFieldMapper.CONTENT_TYPE.equals(mapper.typeName())) {
136+
return compressedBinaryDocValuesFormat;
137+
}
138+
}
139+
130140
if (useTSDBDocValuesFormat(field)) {
131141
return tsdbDocValuesFormat;
132142
}

server/src/main/java/org/elasticsearch/index/codec/tsdb/es819/ES819TSDBDocValuesFormat.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ public ES819TSDBDocValuesFormat() {
128128
this(DEFAULT_SKIP_INDEX_INTERVAL_SIZE, ORDINAL_RANGE_ENCODING_MIN_DOC_PER_ORDINAL, OPTIMIZED_MERGE_ENABLE_DEFAULT, BinaryDVCompressionMode.COMPRESSED_WITH_LZ4);
129129
}
130130

131+
public ES819TSDBDocValuesFormat(BinaryDVCompressionMode binaryDVCompressionMode) {
132+
this(DEFAULT_SKIP_INDEX_INTERVAL_SIZE, ORDINAL_RANGE_ENCODING_MIN_DOC_PER_ORDINAL, OPTIMIZED_MERGE_ENABLE_DEFAULT, binaryDVCompressionMode);
133+
}
134+
131135
/** Doc values fields format with specified skipIndexIntervalSize. */
132136
public ES819TSDBDocValuesFormat(int skipIndexIntervalSize, int minDocsPerOrdinalForRangeEncoding, boolean enableOptimizedMerge, BinaryDVCompressionMode binaryDVCompressionMode) {
133137
super(CODEC_NAME);

0 commit comments

Comments
 (0)