Skip to content

Commit

Permalink
Add initialization in callback
Browse files Browse the repository at this point in the history
Signed-off-by: Siddhant Deshmukh <deshsid@amazon.com>
  • Loading branch information
deshsidd committed Oct 13, 2023
1 parent 1a6e858 commit 39dc8d9
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public class TransportSearchAction extends HandledTransportAction<SearchRequest,

private final MetricsRegistry metricsRegistry;

private final SearchQueryCategorizor searchQueryCategorizor;
private SearchQueryCategorizor searchQueryCategorizor;

@Inject
public TransportSearchAction(
Expand Down Expand Up @@ -221,15 +221,13 @@ public TransportSearchAction(
this.isSearchQueryCategorizationEnabled = clusterService.getClusterSettings().get(SEARCH_QUERY_CATEGORIZATION_ENABLED_SETTING);
clusterService.getClusterSettings()
.addSettingsUpdateConsumer(SEARCH_QUERY_CATEGORIZATION_ENABLED_SETTING, this::setIsSearchQueryCategorizationEnabled);
if (isSearchQueryCategorizationEnabled) {
this.searchQueryCategorizor = new SearchQueryCategorizor(metricsRegistry);
} else {
this.searchQueryCategorizor = null;
}
}

private void setIsSearchQueryCategorizationEnabled(boolean isSearchQueryCategorizationEnabled) {
this.isSearchQueryCategorizationEnabled = isSearchQueryCategorizationEnabled;
if (this.isSearchQueryCategorizationEnabled && this.searchQueryCategorizor == null) {
this.searchQueryCategorizor = new SearchQueryCategorizor(metricsRegistry);
}
}

private void setIsRequestStatsEnabled(boolean isRequestStatsEnabled) {
Expand Down

0 comments on commit 39dc8d9

Please sign in to comment.