Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
easyice committed Sep 19, 2023
1 parent 9ce92a9 commit 862fbed
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions server/src/main/java/org/elasticsearch/index/IndexSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.index.translog.Translog;
import org.elasticsearch.indices.IndicesRequestCache;
import org.elasticsearch.ingest.IngestService;
import org.elasticsearch.node.Node;

Expand Down Expand Up @@ -756,6 +757,7 @@ private void setRetentionLeaseMillis(final TimeValue retentionLease) {
private volatile long mappingDepthLimit;
private volatile long mappingFieldNameLengthLimit;
private volatile long mappingDimensionFieldsLimit;
private volatile boolean requestCacheEnabled;

/**
* The maximum number of refresh listeners allows on this shard.
Expand Down Expand Up @@ -902,6 +904,7 @@ public IndexSettings(final IndexMetadata indexMetadata, final Settings nodeSetti
mappingDimensionFieldsLimit = scopedSettings.get(INDEX_MAPPING_DIMENSION_FIELDS_LIMIT_SETTING);
indexRouting = IndexRouting.fromIndexMetadata(indexMetadata);
es87TSDBCodecEnabled = scopedSettings.get(TIME_SERIES_ES87TSDB_CODEC_ENABLED_SETTING);
requestCacheEnabled = scopedSettings.get(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING);

scopedSettings.addSettingsUpdateConsumer(
MergePolicyConfig.INDEX_COMPOUND_FORMAT_SETTING,
Expand Down Expand Up @@ -980,6 +983,7 @@ public IndexSettings(final IndexMetadata indexMetadata, final Settings nodeSetti
scopedSettings.addSettingsUpdateConsumer(INDEX_MAPPING_DEPTH_LIMIT_SETTING, this::setMappingDepthLimit);
scopedSettings.addSettingsUpdateConsumer(INDEX_MAPPING_FIELD_NAME_LENGTH_LIMIT_SETTING, this::setMappingFieldNameLengthLimit);
scopedSettings.addSettingsUpdateConsumer(INDEX_MAPPING_DIMENSION_FIELDS_LIMIT_SETTING, this::setMappingDimensionFieldsLimit);
scopedSettings.addSettingsUpdateConsumer(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING, this::setRequestCacheEnabled);
}

private void setSearchIdleAfter(TimeValue searchIdleAfter) {
Expand Down Expand Up @@ -1543,6 +1547,14 @@ private void setMappingDimensionFieldsLimit(long value) {
this.mappingDimensionFieldsLimit = value;
}

public boolean isRequestCacheEnabled() {
return requestCacheEnabled;
}

public void setRequestCacheEnabled(boolean requestCacheEnabled) {
this.requestCacheEnabled = requestCacheEnabled;
}

/**
* The bounds for {@code @timestamp} on this index or
* {@code null} if there are no bounds.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1521,7 +1521,7 @@ public static boolean canCache(ShardSearchRequest request, SearchContext context
IndexSettings settings = context.indexShard().indexSettings();
// if not explicitly set in the request, use the index setting, if not, use the request
if (request.requestCache() == null) {
if (settings.getValue(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING) == false) {
if (settings.isRequestCacheEnabled() == false) {
return false;
} else if (context.size() != 0) {
// If no request cache query parameter and shard request cache
Expand Down

0 comments on commit 862fbed

Please sign in to comment.