Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding cluster setting for search ignore unavailable #187

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,10 @@ private void executeSearch(
// No user preference defined in search request - apply cluster service default
searchRequest.allowPartialSearchResults(searchService.defaultAllowPartialSearchResults());
}
if (searchRequest.ignoreUnavailable() == null) {
// No user preference defined in search request - apply cluster service default
searchRequest.ignoreUnavailable(searchService.defaultIgnoreUnavailable());
}
if (searchRequest.isSuggestOnly()) {
// disable request cache if we have only suggest
searchRequest.requestCache(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ public void apply(Settings value, Settings current, Settings previous) {
ClusterManagerService.CLUSTER_MANAGER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING,
SearchService.DEFAULT_SEARCH_TIMEOUT_SETTING,
SearchService.DEFAULT_ALLOW_PARTIAL_SEARCH_RESULTS,
SearchService.DEFAULT_IGNORE_UNAVAILABLE,
TransportSearchAction.SHARD_COUNT_LIMIT_SETTING,
TransportSearchAction.SEARCH_CANCEL_AFTER_TIME_INTERVAL_SETTING,
TransportSearchAction.SEARCH_QUERY_METRICS_ENABLED_SETTING,
Expand Down
22 changes: 22 additions & 0 deletions server/src/main/java/org/opensearch/search/SearchService.java
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,14 @@ public class SearchService extends AbstractLifecycleComponent implements IndexEv
Property.NodeScope
);

// Keeping the default value to maintain existing behaviour
public static final Setting<Boolean> DEFAULT_IGNORE_UNAVAILABLE = Setting.boolSetting(
"search.default_ignore_unavailable",
false,
Property.Dynamic,
Property.NodeScope
);

public static final Setting<Integer> MAX_OPEN_SCROLL_CONTEXT = Setting.intSetting(
"search.max_open_scroll_context",
500,
Expand Down Expand Up @@ -312,6 +320,8 @@ public class SearchService extends AbstractLifecycleComponent implements IndexEv

private volatile boolean defaultAllowPartialSearchResults;

private volatile boolean defaultIgnoreUnavailable;

private volatile boolean lowLevelCancellation;

private volatile int maxOpenScrollContext;
Expand Down Expand Up @@ -381,6 +391,10 @@ public SearchService(
clusterService.getClusterSettings()
.addSettingsUpdateConsumer(DEFAULT_ALLOW_PARTIAL_SEARCH_RESULTS, this::setDefaultAllowPartialSearchResults);

defaultIgnoreUnavailable = DEFAULT_IGNORE_UNAVAILABLE.get(settings);
clusterService.getClusterSettings()
.addSettingsUpdateConsumer(DEFAULT_IGNORE_UNAVAILABLE, this::setDefaultIgnoreUnavailable);

maxOpenScrollContext = MAX_OPEN_SCROLL_CONTEXT.get(settings);
clusterService.getClusterSettings().addSettingsUpdateConsumer(MAX_OPEN_SCROLL_CONTEXT, this::setMaxOpenScrollContext);

Expand Down Expand Up @@ -453,6 +467,14 @@ public boolean defaultAllowPartialSearchResults() {
return defaultAllowPartialSearchResults;
}

private void setDefaultIgnoreUnavailable(boolean defaultIgnoreUnavailable) {
this.defaultIgnoreUnavailable = defaultIgnoreUnavailable;
}

public boolean defaultIgnoreUnavailable() {
return defaultIgnoreUnavailable;
}

private void setMaxOpenScrollContext(int maxOpenScrollContext) {
this.maxOpenScrollContext = maxOpenScrollContext;
}
Expand Down
Loading