Skip to content

Commit

Permalink
Add index settings
Browse files Browse the repository at this point in the history
  • Loading branch information
dnhatn committed Jul 13, 2022
1 parent 291043a commit 22c6a0e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ public final class IndexScopedSettings extends AbstractScopedSettings {
DiskThresholdDecider.SETTING_IGNORE_DISK_WATERMARKS,
ShardLimitValidator.INDEX_SETTING_SHARD_LIMIT_GROUP,
DataTier.TIER_PREFERENCE_SETTING,
IndexSettings.BLOOM_FILTER_ID_FIELD_ENABLED_SETTING,

// validate that built-in similarities don't get redefined
Setting.groupSetting("index.similarity.", (s) -> {
Expand Down
11 changes: 11 additions & 0 deletions server/src/main/java/org/elasticsearch/index/IndexSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,17 @@ public final class IndexSettings {
Setting.Property.IndexScope
);

/**
* This index setting is intentionally undocumented and should be used as an escape hatch to disable BloomFilter of the
* _id field of non-data-stream indices, which is enabled by default. This setting doesn't affect data-stream indices.
*/
public static final Setting<Boolean> BLOOM_FILTER_ID_FIELD_ENABLED_SETTING = Setting.boolSetting(
"index.bloom_filter_for_id_field.enabled",
true,
Setting.Property.Dynamic,
Setting.Property.IndexScope
);

/**
* Is the {@code index.mode} enabled? It should only be enbaled if you
* pass a jvm parameter or are running a snapshot build.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.apache.lucene.codecs.lucene93.Lucene93Codec;
import org.elasticsearch.common.lucene.Lucene;
import org.elasticsearch.common.util.BigArrays;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.codec.bloomfilter.ES84BloomFilterPostingsFormat;
import org.elasticsearch.index.mapper.IdFieldMapper;
import org.elasticsearch.index.mapper.Mapper;
Expand Down Expand Up @@ -49,8 +50,11 @@ public PerFieldMapperCodec(Mode compressionMode, MapperService mapperService, Bi

@Override
public PostingsFormat getPostingsFormatForField(String field) {
if (IdFieldMapper.NAME.equals(field) && mapperService.mappingLookup().isDataStreamTimestampFieldEnabled() == false) {
if (IdFieldMapper.NAME.equals(field)
&& mapperService.mappingLookup().isDataStreamTimestampFieldEnabled() == false
&& IndexSettings.BLOOM_FILTER_ID_FIELD_ENABLED_SETTING.get(mapperService.getIndexSettings().getSettings())) {
return new ES84BloomFilterPostingsFormat(super.getPostingsFormatForField(field), bigArrays);

}
final PostingsFormat format = mapperService.mappingLookup().getPostingsFormat(field);
if (format != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,9 @@ protected Settings.Builder setRandomIndexSettings(Random random, Settings.Builde
RandomNumbers.randomIntBetween(random, 1, 15) + "ms"
);
}

if (randomBoolean()) {
builder.put(IndexSettings.BLOOM_FILTER_ID_FIELD_ENABLED_SETTING.getKey(), randomBoolean());
}
return builder;
}

Expand Down

0 comments on commit 22c6a0e

Please sign in to comment.