diff --git a/server/src/main/java/org/opensearch/action/search/SearchQueryCategorizor.java b/server/src/main/java/org/opensearch/action/search/SearchQueryCategorizor.java index b30ea600ce12c..0da95845d1b3b 100644 --- a/server/src/main/java/org/opensearch/action/search/SearchQueryCategorizor.java +++ b/server/src/main/java/org/opensearch/action/search/SearchQueryCategorizor.java @@ -44,7 +44,7 @@ public void categorize(SearchSourceBuilder source) { } private void incrementQuerySortCounters(List> sorts) { - if (sorts.size() > 0) { + if (sorts != null && sorts.size() > 0) { searchQueryCounters.sortCounter.add(1); } } diff --git a/server/src/main/java/org/opensearch/action/search/TransportSearchAction.java b/server/src/main/java/org/opensearch/action/search/TransportSearchAction.java index 4fa342893d533..cee57482c2c50 100644 --- a/server/src/main/java/org/opensearch/action/search/TransportSearchAction.java +++ b/server/src/main/java/org/opensearch/action/search/TransportSearchAction.java @@ -60,7 +60,6 @@ import org.opensearch.common.settings.Setting; import org.opensearch.common.settings.Setting.Property; import org.opensearch.common.unit.TimeValue; -import org.opensearch.common.util.FeatureFlags; import org.opensearch.common.util.concurrent.AtomicArray; import org.opensearch.common.util.concurrent.CountDown; import org.opensearch.core.action.ActionListener; @@ -138,6 +137,13 @@ public class TransportSearchAction extends HandledTransportAction SEARCH_QUERY_CATEGORIZATION_ENABLED_SETTING = Setting.boolSetting( + "search.query.categorization.enabled", + false, + Setting.Property.NodeScope, + Setting.Property.Dynamic + ); + // cluster level setting for timeout based search cancellation. If search request level parameter is present then that will take // precedence over the cluster setting value public static final String SEARCH_CANCEL_AFTER_TIME_INTERVAL_SETTING_KEY = "search.cancel_after_time_interval"; @@ -170,6 +176,8 @@ public class TransportSearchAction extends HandledTransportAction