From 55496a4147198ab87a72c613363a545d4363f5b1 Mon Sep 17 00:00:00 2001 From: Harsha Vamsi Kalluri Date: Wed, 5 Jun 2024 18:22:39 +0000 Subject: [PATCH] Revert static Signed-off-by: Harsha Vamsi Kalluri --- .../opensearch/index/search/QueryParserHelper.java | 2 +- .../java/org/opensearch/search/SearchService.java | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/server/src/main/java/org/opensearch/index/search/QueryParserHelper.java b/server/src/main/java/org/opensearch/index/search/QueryParserHelper.java index 1689234303d78..568fb4c5ddf58 100644 --- a/server/src/main/java/org/opensearch/index/search/QueryParserHelper.java +++ b/server/src/main/java/org/opensearch/index/search/QueryParserHelper.java @@ -177,7 +177,7 @@ static Map resolveMappingField( } static void checkForTooManyFields(int numberOfFields, QueryShardContext context, @Nullable String inputPattern) { - Integer limit = SearchService.getMaxClauseCount(); + int limit = SearchService.INDICES_MAX_CLAUSE_COUNT_SETTING.get(context.getIndexSettings().getSettings()); if (numberOfFields > limit) { StringBuilder errorMsg = new StringBuilder("field expansion "); if (inputPattern != null) { diff --git a/server/src/main/java/org/opensearch/search/SearchService.java b/server/src/main/java/org/opensearch/search/SearchService.java index 474e4facd12dc..58ad94e37b914 100644 --- a/server/src/main/java/org/opensearch/search/SearchService.java +++ b/server/src/main/java/org/opensearch/search/SearchService.java @@ -328,7 +328,7 @@ public class SearchService extends AbstractLifecycleComponent implements IndexEv private volatile int maxOpenPitContext; - private static volatile int maxClauseCount; + private volatile int maxClauseCount; private final Cancellable keepAliveReaper; @@ -403,7 +403,7 @@ public SearchService( clusterService.getClusterSettings().addSettingsUpdateConsumer(LOW_LEVEL_CANCELLATION_SETTING, this::setLowLevelCancellation); setMaxClauseCount(INDICES_MAX_CLAUSE_COUNT_SETTING.get(settings)); - clusterService.getClusterSettings().addSettingsUpdateConsumer(INDICES_MAX_CLAUSE_COUNT_SETTING, SearchService::setMaxClauseCount); + clusterService.getClusterSettings().addSettingsUpdateConsumer(INDICES_MAX_CLAUSE_COUNT_SETTING, this::setMaxClauseCount); } private void validateKeepAlives(TimeValue defaultKeepAlive, TimeValue maxKeepAlive) { @@ -480,15 +480,11 @@ private void setLowLevelCancellation(Boolean lowLevelCancellation) { this.lowLevelCancellation = lowLevelCancellation; } - private static void setMaxClauseCount(int maxClauseCount) { - SearchService.maxClauseCount = maxClauseCount; + private void setMaxClauseCount(int maxClauseCount) { + this.maxClauseCount = maxClauseCount; IndexSearcher.setMaxClauseCount(maxClauseCount); } - public static int getMaxClauseCount() { - return SearchService.maxClauseCount; - } - @Override public void afterIndexRemoved(Index index, IndexSettings indexSettings, IndexRemovalReason reason) {