Skip to content
Open
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 @@ -126,6 +126,7 @@
import org.elasticsearch.search.SearchService;
import org.elasticsearch.search.aggregations.MultiBucketConsumerService;
import org.elasticsearch.search.aggregations.metrics.TDigestExecutionHint;
import org.elasticsearch.search.fetch.subphase.FetchSourceContext;
import org.elasticsearch.search.fetch.subphase.highlight.FastVectorHighlighter;
import org.elasticsearch.snapshots.InternalSnapshotsInfoService;
import org.elasticsearch.snapshots.RestoreService;
Expand Down Expand Up @@ -547,6 +548,7 @@ public void apply(Settings value, Settings current, Settings previous) {
ThreadPool.SLOW_SCHEDULER_TASK_WARN_THRESHOLD_SETTING,
ThreadPool.WRITE_THREAD_POOLS_EWMA_ALPHA_SETTING,
FastVectorHighlighter.SETTING_TV_HIGHLIGHT_MULTI_VALUE,
FetchSourceContext.DEFAULT_SOURCE_EXCLUDE_VECTORS,
Node.BREAKER_TYPE_KEY,
OperationRouting.USE_ADAPTIVE_REPLICA_SELECTION_SETTING,
IndexGraveyard.SETTING_MAX_TOMBSTONES,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
import org.elasticsearch.search.fetch.ShardFetchRequest;
import org.elasticsearch.search.fetch.subphase.FetchDocValuesContext;
import org.elasticsearch.search.fetch.subphase.FetchFieldsContext;
import org.elasticsearch.search.fetch.subphase.FetchSourceContext;
import org.elasticsearch.search.fetch.subphase.ScriptFieldsContext.ScriptField;
import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder;
import org.elasticsearch.search.internal.AliasFilter;
Expand Down Expand Up @@ -445,6 +446,9 @@ public SearchService(
clusterService.getClusterSettings()
.addSettingsUpdateConsumer(MEMORY_ACCOUNTING_BUFFER_SIZE, newValue -> this.memoryAccountingBufferSize = newValue.getBytes());
prewarmingMaxPoolFactorThreshold = PREWARMING_THRESHOLD_THREADPOOL_SIZE_FACTOR_POOL_SIZE.get(settings);

clusterService.getClusterSettings()
.initializeAndWatch(FetchSourceContext.DEFAULT_SOURCE_EXCLUDE_VECTORS, FetchSourceContext::setDefaultSourceExcludeVectors);
}

public CircuitBreaker getCircuitBreaker() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.core.Nullable;
import org.elasticsearch.rest.RestRequest;
Expand All @@ -40,6 +41,14 @@ public class FetchSourceContext implements Writeable, ToXContentObject {
public static final ParseField INCLUDES_FIELD = new ParseField("includes", "include");
public static final ParseField EXCLUDES_FIELD = new ParseField("excludes", "exclude");

public static final Setting<Boolean> DEFAULT_SOURCE_EXCLUDE_VECTORS = Setting.boolSetting(
"search.default_exclude_vectors",
true,
Setting.Property.NodeScope,
Setting.Property.Dynamic
);
private static volatile Boolean defaultSourceExcludeVectors;

public static final FetchSourceContext FETCH_SOURCE = new FetchSourceContext(true, null, Strings.EMPTY_ARRAY, Strings.EMPTY_ARRAY);
public static final FetchSourceContext FETCH_ALL_SOURCE = new FetchSourceContext(true, false, Strings.EMPTY_ARRAY, Strings.EMPTY_ARRAY);

Expand Down Expand Up @@ -89,6 +98,14 @@ public static FetchSourceContext readFrom(StreamInput in) throws IOException {
return of(fetchSource, excludeVectors, includes, excludes);
}

public static void setDefaultSourceExcludeVectors(boolean defaultSourceExcludeVectors) {
if (defaultSourceExcludeVectors) {
FetchSourceContext.defaultSourceExcludeVectors = null;
} else {
FetchSourceContext.defaultSourceExcludeVectors = false;
}
}

@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeBoolean(fetchSource);
Expand Down Expand Up @@ -157,7 +174,7 @@ public static FetchSourceContext parseFromRestRequest(RestRequest request) {
sourceExcludes = Strings.splitStringByCommaToArray(sExcludes);
}

Boolean excludeVectors = request.paramAsBoolean("_source_exclude_vectors", null);
Boolean excludeVectors = request.paramAsBoolean("_source_exclude_vectors", defaultSourceExcludeVectors);

if (excludeVectors != null || fetchSource != null || sourceIncludes != null || sourceExcludes != null) {
return FetchSourceContext.of(fetchSource == null || fetchSource, excludeVectors, sourceIncludes, sourceExcludes);
Expand Down