Skip to content

Commit

Permalink
Revert static
Browse files Browse the repository at this point in the history
Signed-off-by: Harsha Vamsi Kalluri <[email protected]>
  • Loading branch information
harshavamsi committed Jun 5, 2024
1 parent de6d547 commit 55496a4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ static Map<String, Float> 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) {
Expand Down
12 changes: 4 additions & 8 deletions server/src/main/java/org/opensearch/search/SearchService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 55496a4

Please sign in to comment.