From 9124c94a6c75b856fbd2c31a5b6bdb94b5e160d5 Mon Sep 17 00:00:00 2001 From: Julie Tibshirani Date: Mon, 23 Sep 2019 13:21:37 -0700 Subject: [PATCH] Add support for aliases in queries on _index. (#46944) Previously, queries on the _index field were not able to specify index aliases. This was a regression in functionality compared to the 'indices' query that was deprecated and removed in 6.0. Now queries on _index can specify an alias, which is resolved to the concrete index names when we check whether an index matches. To match a remote shard target, the pattern needs to be of the form 'cluster:index' to match the fully-qualified index name. Index aliases can be specified in the following query types: term, terms, prefix, and wildcard. --- docs/reference/migration/migrate_7_5.asciidoc | 30 +++++++ .../multi_cluster/90_index_name_query.yml | 58 ++++++++++++ .../org/elasticsearch/index/IndexModule.java | 4 +- .../org/elasticsearch/index/IndexService.java | 9 +- .../index/mapper/IndexFieldMapper.java | 42 ++++----- .../index/query/QueryShardContext.java | 73 +++++++++------ .../index/query/SearchIndexNameMatcher.java | 84 +++++++++++++++++ .../elasticsearch/indices/IndicesService.java | 6 +- .../java/org/elasticsearch/node/Node.java | 8 +- .../elasticsearch/index/IndexModuleTests.java | 2 +- .../index/mapper/DateFieldTypeTests.java | 4 +- .../mapper/FieldNamesFieldTypeTests.java | 2 +- .../index/mapper/IndexFieldTypeTests.java | 24 +++-- .../index/mapper/RangeFieldTypeTests.java | 2 +- .../query/IntervalQueryBuilderTests.java | 2 +- .../index/query/QueryShardContextTests.java | 22 +---- .../index/query/RangeQueryRewriteTests.java | 9 +- .../query/SearchIndexNameMatcherTests.java | 90 +++++++++++++++++++ .../query/SimpleQueryStringBuilderTests.java | 10 --- .../query/WildcardQueryBuilderTests.java | 15 ---- .../bucket/histogram/ExtendedBoundsTests.java | 2 +- .../ScriptedMetricAggregatorTests.java | 2 +- .../highlight/HighlightBuilderTests.java | 2 +- .../rescore/QueryRescorerBuilderTests.java | 4 +- .../search/sort/AbstractSortTestCase.java | 2 +- .../AbstractSuggestionBuilderTestCase.java | 2 +- .../snapshots/SnapshotResiliencyTests.java | 1 + .../aggregations/AggregatorTestCase.java | 8 +- .../test/AbstractBuilderTestCase.java | 2 +- .../search/MockSearchServiceTests.java | 2 +- .../DocumentSubsetBitsetCacheTests.java | 2 +- ...ityIndexReaderWrapperIntegrationTests.java | 4 +- .../job/RollupIndexerIndexingTests.java | 2 +- 33 files changed, 392 insertions(+), 139 deletions(-) create mode 100644 docs/reference/migration/migrate_7_5.asciidoc create mode 100644 qa/multi-cluster-search/src/test/resources/rest-api-spec/test/multi_cluster/90_index_name_query.yml create mode 100644 server/src/main/java/org/elasticsearch/index/query/SearchIndexNameMatcher.java create mode 100644 server/src/test/java/org/elasticsearch/index/query/SearchIndexNameMatcherTests.java diff --git a/docs/reference/migration/migrate_7_5.asciidoc b/docs/reference/migration/migrate_7_5.asciidoc new file mode 100644 index 00000000000..2334ce8aa5a --- /dev/null +++ b/docs/reference/migration/migrate_7_5.asciidoc @@ -0,0 +1,30 @@ +[[breaking-changes-7.5]] +== Breaking changes in 7.5 +++++ +7.5 +++++ + +This section discusses the changes that you need to be aware of when migrating +your application to Elasticsearch 7.5. + +See also <> and <>. + +coming[7.5.0] + +//NOTE: The notable-breaking-changes tagged regions are re-used in the +//Installation and Upgrade Guide + +//tag::notable-breaking-changes[] + +//end::notable-breaking-changes[] + +[discrete] +[[breaking_75_search_changes]] +=== Search Changes + +[discrete] +==== Stricter checking for wildcard queries on _index +Previously, a wildcard query on the `_index` field matched directly against the +fully-qualified index name. Now, in order to match against remote indices like +i`cluster:index`, the query must contain a colon, as in `cl*ster:inde*`. This +behavior aligns with the way indices are matched in the search endpoint. diff --git a/qa/multi-cluster-search/src/test/resources/rest-api-spec/test/multi_cluster/90_index_name_query.yml b/qa/multi-cluster-search/src/test/resources/rest-api-spec/test/multi_cluster/90_index_name_query.yml new file mode 100644 index 00000000000..030dad662df --- /dev/null +++ b/qa/multi-cluster-search/src/test/resources/rest-api-spec/test/multi_cluster/90_index_name_query.yml @@ -0,0 +1,58 @@ +--- +setup: + - do: + indices.create: + index: single_doc_index + body: + settings: + index: + number_of_shards: 1 + number_of_replicas: 0 +--- +teardown: + - do: + indices.delete: + index: single_doc_index + ignore_unavailable: true + +--- +"Test that queries on _index match against the correct indices.": + + - do: + bulk: + refresh: true + body: + - '{"index": {"_index": "single_doc_index"}}' + - '{"f1": "local_cluster", "sort_field": 0}' + + - do: + search: + rest_total_hits_as_int: true + index: "single_doc_index,my_remote_cluster:single_doc_index" + body: + query: + term: + "_index": "single_doc_index" + + - match: { hits.total: 1 } + - match: { hits.hits.0._index: "single_doc_index"} + - match: { _shards.total: 2 } + - match: { _shards.successful: 2 } + - match: { _shards.skipped : 0} + - match: { _shards.failed: 0 } + + - do: + search: + rest_total_hits_as_int: true + index: "single_doc_index,my_remote_cluster:single_doc_index" + body: + query: + term: + "_index": "my_remote_cluster:single_doc_index" + + - match: { hits.total: 1 } + - match: { hits.hits.0._index: "my_remote_cluster:single_doc_index"} + - match: { _shards.total: 2 } + - match: { _shards.successful: 2 } + - match: { _shards.skipped : 0} + - match: { _shards.failed: 0 } diff --git a/server/src/main/java/org/elasticsearch/index/IndexModule.java b/server/src/main/java/org/elasticsearch/index/IndexModule.java index 6ef335144eb..b10d84ef1c6 100644 --- a/server/src/main/java/org/elasticsearch/index/IndexModule.java +++ b/server/src/main/java/org/elasticsearch/index/IndexModule.java @@ -30,6 +30,7 @@ import org.apache.lucene.util.Constants; import org.apache.lucene.util.SetOnce; import org.elasticsearch.Version; import org.elasticsearch.client.Client; +import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.CheckedFunction; import org.elasticsearch.common.TriFunction; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; @@ -386,6 +387,7 @@ public final class IndexModule { BigArrays bigArrays, ThreadPool threadPool, ScriptService scriptService, + ClusterService clusterService, Client client, IndicesQueryCache indicesQueryCache, MapperRegistry mapperRegistry, @@ -411,7 +413,7 @@ public final class IndexModule { return new IndexService(indexSettings, indexCreationContext, environment, xContentRegistry, new SimilarityService(indexSettings, scriptService, similarities), shardStoreDeleter, analysisRegistry, engineFactory, circuitBreakerService, bigArrays, threadPool, scriptService, - client, queryCache, directoryFactory, eventListener, readerWrapperFactory, mapperRegistry, + clusterService, client, queryCache, directoryFactory, eventListener, readerWrapperFactory, mapperRegistry, indicesFieldDataCache, searchOperationListeners, indexOperationListeners, namedWriteableRegistry); } diff --git a/server/src/main/java/org/elasticsearch/index/IndexService.java b/server/src/main/java/org/elasticsearch/index/IndexService.java index da470a04afa..5e2ac0dbac6 100644 --- a/server/src/main/java/org/elasticsearch/index/IndexService.java +++ b/server/src/main/java/org/elasticsearch/index/IndexService.java @@ -32,6 +32,7 @@ import org.elasticsearch.Version; import org.elasticsearch.client.Client; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.routing.ShardRouting; +import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.CheckedFunction; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; @@ -57,6 +58,7 @@ import org.elasticsearch.index.engine.EngineFactory; import org.elasticsearch.index.fielddata.IndexFieldDataCache; import org.elasticsearch.index.fielddata.IndexFieldDataService; import org.elasticsearch.index.mapper.MapperService; +import org.elasticsearch.index.query.SearchIndexNameMatcher; import org.elasticsearch.index.query.QueryShardContext; import org.elasticsearch.index.seqno.RetentionLeaseSyncer; import org.elasticsearch.index.shard.IndexEventListener; @@ -134,6 +136,7 @@ public class IndexService extends AbstractIndexComponent implements IndicesClust private final ThreadPool threadPool; private final BigArrays bigArrays; private final ScriptService scriptService; + private final ClusterService clusterService; private final Client client; private final CircuitBreakerService circuitBreakerService; private Supplier indexSortSupplier; @@ -151,6 +154,7 @@ public class IndexService extends AbstractIndexComponent implements IndicesClust BigArrays bigArrays, ThreadPool threadPool, ScriptService scriptService, + ClusterService clusterService, Client client, QueryCache queryCache, IndexStorePlugin.DirectoryFactory directoryFactory, @@ -201,6 +205,7 @@ public class IndexService extends AbstractIndexComponent implements IndicesClust this.bigArrays = bigArrays; this.threadPool = threadPool; this.scriptService = scriptService; + this.clusterService = clusterService; this.client = client; this.eventListener = eventListener; this.nodeEnv = nodeEnv; @@ -530,9 +535,11 @@ public class IndexService extends AbstractIndexComponent implements IndicesClust * {@link IndexReader}-specific optimizations, such as rewriting containing range queries. */ public QueryShardContext newQueryShardContext(int shardId, IndexSearcher searcher, LongSupplier nowInMillis, String clusterAlias) { + SearchIndexNameMatcher indexNameMatcher = new SearchIndexNameMatcher(index().getName(), clusterAlias, clusterService); return new QueryShardContext( shardId, indexSettings, bigArrays, indexCache.bitsetFilterCache(), indexFieldData::getForField, mapperService(), - similarityService(), scriptService, xContentRegistry, namedWriteableRegistry, client, searcher, nowInMillis, clusterAlias); + similarityService(), scriptService, xContentRegistry, namedWriteableRegistry, client, searcher, nowInMillis, clusterAlias, + indexNameMatcher); } /** diff --git a/server/src/main/java/org/elasticsearch/index/mapper/IndexFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/IndexFieldMapper.java index 276a8e7583c..4e690640135 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/IndexFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/IndexFieldMapper.java @@ -129,11 +129,16 @@ public class IndexFieldMapper extends MetadataFieldMapper { */ @Override public Query termQuery(Object value, @Nullable QueryShardContext context) { - if (isSameIndex(value, context.getFullyQualifiedIndex().getName())) { + String pattern = value instanceof BytesRef + ? ((BytesRef) value).utf8ToString() + : value.toString(); + if (context.indexMatches(pattern)) { + // No need to OR these clauses - we can only logically be + // running in the context of just one of these index names. return Queries.newMatchAllQuery(); } else { - return Queries.newMatchNoDocsQuery("Index didn't match. Index queried: " + context.index().getName() - + " vs. " + value); + return Queries.newMatchNoDocsQuery("The index [" + context.getFullyQualifiedIndex().getName() + + "] doesn't match the provided value [" + value + "]."); } } @@ -143,26 +148,29 @@ public class IndexFieldMapper extends MetadataFieldMapper { return super.termsQuery(values, context); } for (Object value : values) { - if (isSameIndex(value, context.getFullyQualifiedIndex().getName())) { + String pattern = value instanceof BytesRef + ? ((BytesRef) value).utf8ToString() + : value.toString(); + if (context.indexMatches(pattern)) { // No need to OR these clauses - we can only logically be // running in the context of just one of these index names. return Queries.newMatchAllQuery(); } } // None of the listed index names are this one - return Queries.newMatchNoDocsQuery("Index didn't match. Index queried: " + context.getFullyQualifiedIndex().getName() - + " vs. " + values); + return Queries.newMatchNoDocsQuery("The index [" + context.getFullyQualifiedIndex().getName() + + "] doesn't match the provided values [" + values + "]."); } @Override public Query prefixQuery(String value, @Nullable MultiTermQuery.RewriteMethod method, QueryShardContext context) { - String indexName = context.getFullyQualifiedIndex().getName(); - if (indexName.startsWith(value)) { + String pattern = value + "*"; + if (context.indexMatches(pattern)) { return Queries.newMatchAllQuery(); } else { - return Queries.newMatchNoDocsQuery("The index [" + indexName + + return Queries.newMatchNoDocsQuery("The index [" + context.getFullyQualifiedIndex().getName() + "] doesn't match the provided prefix [" + value + "]."); } } @@ -176,8 +184,8 @@ public class IndexFieldMapper extends MetadataFieldMapper { if (pattern.matcher(indexName).matches()) { return Queries.newMatchAllQuery(); } else { - return Queries.newMatchNoDocsQuery("The index [" + indexName + - "] doesn't match the provided pattern [" + value + "]."); + return Queries.newMatchNoDocsQuery("The index [" + context.getFullyQualifiedIndex().getName() + + "] doesn't match the provided pattern [" + value + "]."); } } @@ -185,20 +193,14 @@ public class IndexFieldMapper extends MetadataFieldMapper { public Query wildcardQuery(String value, @Nullable MultiTermQuery.RewriteMethod method, QueryShardContext context) { - String indexName = context.getFullyQualifiedIndex().getName(); - if (isSameIndex(value, indexName)) { + if (context.indexMatches(value)) { return Queries.newMatchAllQuery(); } else { - return Queries.newMatchNoDocsQuery("The index [" + indexName + - "] doesn't match the provided pattern [" + value + "]."); + return Queries.newMatchNoDocsQuery("The index [" + context.getFullyQualifiedIndex().getName() + + "] doesn't match the provided pattern [" + value + "]."); } } - private boolean isSameIndex(Object value, String indexName) { - String pattern = value instanceof BytesRef ? ((BytesRef) value).utf8ToString() : value.toString(); - return Regex.simpleMatch(pattern, indexName); - } - @Override public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) { return new ConstantIndexFieldData.Builder(mapperService -> fullyQualifiedIndexName); diff --git a/server/src/main/java/org/elasticsearch/index/query/QueryShardContext.java b/server/src/main/java/org/elasticsearch/index/query/QueryShardContext.java index a631ea319b4..b6eea750748 100644 --- a/server/src/main/java/org/elasticsearch/index/query/QueryShardContext.java +++ b/server/src/main/java/org/elasticsearch/index/query/QueryShardContext.java @@ -69,6 +69,7 @@ import java.util.Set; import java.util.function.BiConsumer; import java.util.function.BiFunction; import java.util.function.LongSupplier; +import java.util.function.Predicate; import static java.util.Collections.unmodifiableMap; @@ -93,7 +94,9 @@ public class QueryShardContext extends QueryRewriteContext { private String[] types = Strings.EMPTY_ARRAY; private boolean cacheable = true; private final SetOnce frozen = new SetOnce<>(); + private final Index fullyQualifiedIndex; + private final Predicate indexNameMatcher; public void setTypes(String... types) { this.types = types; @@ -109,45 +112,48 @@ public class QueryShardContext extends QueryRewriteContext { private NestedScope nestedScope; public QueryShardContext(int shardId, - IndexSettings indexSettings, - BigArrays bigArrays, - BitsetFilterCache bitsetFilterCache, - BiFunction> indexFieldDataLookup, - MapperService mapperService, - SimilarityService similarityService, - ScriptService scriptService, - NamedXContentRegistry xContentRegistry, - NamedWriteableRegistry namedWriteableRegistry, - Client client, - IndexSearcher searcher, - LongSupplier nowInMillis, - String clusterAlias) { + IndexSettings indexSettings, + BigArrays bigArrays, + BitsetFilterCache bitsetFilterCache, + BiFunction> indexFieldDataLookup, + MapperService mapperService, + SimilarityService similarityService, + ScriptService scriptService, + NamedXContentRegistry xContentRegistry, + NamedWriteableRegistry namedWriteableRegistry, + Client client, + IndexSearcher searcher, + LongSupplier nowInMillis, + String clusterAlias, + Predicate indexNameMatcher) { this(shardId, indexSettings, bigArrays, bitsetFilterCache, indexFieldDataLookup, mapperService, similarityService, - scriptService, xContentRegistry, namedWriteableRegistry, client, searcher, nowInMillis, + scriptService, xContentRegistry, namedWriteableRegistry, client, searcher, nowInMillis, indexNameMatcher, new Index(RemoteClusterAware.buildRemoteIndexName(clusterAlias, indexSettings.getIndex().getName()), indexSettings.getIndex().getUUID())); } public QueryShardContext(QueryShardContext source) { this(source.shardId, source.indexSettings, source.bigArrays, source.bitsetFilterCache, source.indexFieldDataService, - source.mapperService, source.similarityService, source.scriptService, source.getXContentRegistry(), - source.getWriteableRegistry(), source.client, source.searcher, source.nowInMillis, source.fullyQualifiedIndex); + source.mapperService, source.similarityService, source.scriptService, source.getXContentRegistry(), + source.getWriteableRegistry(), source.client, source.searcher, source.nowInMillis, source.indexNameMatcher, + source.fullyQualifiedIndex); } private QueryShardContext(int shardId, - IndexSettings indexSettings, - BigArrays bigArrays, - BitsetFilterCache bitsetFilterCache, - BiFunction> indexFieldDataLookup, - MapperService mapperService, - SimilarityService similarityService, - ScriptService scriptService, - NamedXContentRegistry xContentRegistry, - NamedWriteableRegistry namedWriteableRegistry, - Client client, - IndexSearcher searcher, - LongSupplier nowInMillis, - Index fullyQualifiedIndex) { + IndexSettings indexSettings, + BigArrays bigArrays, + BitsetFilterCache bitsetFilterCache, + BiFunction> indexFieldDataLookup, + MapperService mapperService, + SimilarityService similarityService, + ScriptService scriptService, + NamedXContentRegistry xContentRegistry, + NamedWriteableRegistry namedWriteableRegistry, + Client client, + IndexSearcher searcher, + LongSupplier nowInMillis, + Predicate indexNameMatcher, + Index fullyQualifiedIndex) { super(xContentRegistry, namedWriteableRegistry, client, nowInMillis); this.shardId = shardId; this.similarityService = similarityService; @@ -160,6 +166,7 @@ public class QueryShardContext extends QueryRewriteContext { this.scriptService = scriptService; this.indexSettings = indexSettings; this.searcher = searcher; + this.indexNameMatcher = indexNameMatcher; this.fullyQualifiedIndex = fullyQualifiedIndex; } @@ -311,6 +318,14 @@ public class QueryShardContext extends QueryRewriteContext { return indexSettings.getIndexVersionCreated(); } + /** + * Given an index pattern, checks whether it matches against the current shard. The pattern + * may represent a fully qualified index name if the search targets remote shards. + */ + public boolean indexMatches(String pattern) { + return indexNameMatcher.test(pattern); + } + public ParsedQuery toQuery(QueryBuilder queryBuilder) { return toQuery(queryBuilder, q -> { Query query = q.toQuery(this); diff --git a/server/src/main/java/org/elasticsearch/index/query/SearchIndexNameMatcher.java b/server/src/main/java/org/elasticsearch/index/query/SearchIndexNameMatcher.java new file mode 100644 index 00000000000..b2329d1d54c --- /dev/null +++ b/server/src/main/java/org/elasticsearch/index/query/SearchIndexNameMatcher.java @@ -0,0 +1,84 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.index.query; + +import org.elasticsearch.action.support.IndicesOptions; +import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; +import org.elasticsearch.cluster.service.ClusterService; +import org.elasticsearch.common.regex.Regex; +import org.elasticsearch.transport.RemoteClusterAware; + +import java.util.function.Predicate; + +/** + * A predicate that checks whether an index pattern matches the current search shard target. + */ +public class SearchIndexNameMatcher implements Predicate { + private final String indexName; + private final String clusterAlias; + private final ClusterService clusterService; + private final IndexNameExpressionResolver expressionResolver; + + /** + * Creates a new index name matcher. + * + * @param indexName he name of the local index. + * @param clusterAlias the cluster alias of this search shard target. If it is a local target, the alias + * should be null or equal to {@link RemoteClusterAware#LOCAL_CLUSTER_GROUP_KEY}. + * @param clusterService the cluster service. + */ + public SearchIndexNameMatcher(String indexName, + String clusterAlias, + ClusterService clusterService) { + this.indexName = indexName; + this.clusterAlias = RemoteClusterAware.LOCAL_CLUSTER_GROUP_KEY.equals(clusterAlias) ? null : clusterAlias; + this.clusterService = clusterService; + this.expressionResolver = new IndexNameExpressionResolver(); + } + + /** + * Given an index pattern, checks whether it matches against the current shard. + * + * If this shard represents a remote shard target, then in order to match the pattern contain + * the separator ':', and must match on both the cluster alias and index name. + */ + public boolean test(String pattern) { + int separatorIndex = pattern.indexOf(RemoteClusterAware.REMOTE_CLUSTER_INDEX_SEPARATOR); + if (separatorIndex < 0) { + return clusterAlias == null && matchesIndex(pattern); + } else { + String clusterPattern = pattern.substring(0, separatorIndex); + String indexPattern = pattern.substring(separatorIndex + 1); + + return Regex.simpleMatch(clusterPattern, clusterAlias) && matchesIndex(indexPattern); + } + } + + private boolean matchesIndex(String pattern) { + String[] concreteIndices = expressionResolver.concreteIndexNames( + clusterService.state(), IndicesOptions.lenientExpandOpen(), pattern); + for (String index : concreteIndices) { + if (Regex.simpleMatch(index, indexName)) { + return true; + } + } + return false; + } +} diff --git a/server/src/main/java/org/elasticsearch/indices/IndicesService.java b/server/src/main/java/org/elasticsearch/indices/IndicesService.java index 38ab7149521..b6c87e576bd 100644 --- a/server/src/main/java/org/elasticsearch/indices/IndicesService.java +++ b/server/src/main/java/org/elasticsearch/indices/IndicesService.java @@ -43,6 +43,7 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.routing.RecoverySource; import org.elasticsearch.cluster.routing.ShardRouting; +import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.CheckedFunction; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.breaker.CircuitBreaker; @@ -186,6 +187,7 @@ public class IndicesService extends AbstractLifecycleComponent private final CircuitBreakerService circuitBreakerService; private final BigArrays bigArrays; private final ScriptService scriptService; + private final ClusterService clusterService; private final Client client; private volatile Map indices = emptyMap(); private final Map> pendingDeletes = new HashMap<>(); @@ -213,7 +215,7 @@ public class IndicesService extends AbstractLifecycleComponent AnalysisRegistry analysisRegistry, IndexNameExpressionResolver indexNameExpressionResolver, MapperRegistry mapperRegistry, NamedWriteableRegistry namedWriteableRegistry, ThreadPool threadPool, IndexScopedSettings indexScopedSettings, CircuitBreakerService circuitBreakerService, BigArrays bigArrays, - ScriptService scriptService, Client client, MetaStateService metaStateService, + ScriptService scriptService, ClusterService clusterService, Client client, MetaStateService metaStateService, Collection>> engineFactoryProviders, Map directoryFactories) { this.settings = settings; @@ -235,6 +237,7 @@ public class IndicesService extends AbstractLifecycleComponent this.circuitBreakerService = circuitBreakerService; this.bigArrays = bigArrays; this.scriptService = scriptService; + this.clusterService = clusterService; this.client = client; this.indicesFieldDataCache = new IndicesFieldDataCache(settings, new IndexFieldDataCache.Listener() { @Override @@ -556,6 +559,7 @@ public class IndicesService extends AbstractLifecycleComponent bigArrays, threadPool, scriptService, + clusterService, client, indicesQueryCache, mapperRegistry, diff --git a/server/src/main/java/org/elasticsearch/node/Node.java b/server/src/main/java/org/elasticsearch/node/Node.java index 86a55ceb47a..efa7ddcd657 100644 --- a/server/src/main/java/org/elasticsearch/node/Node.java +++ b/server/src/main/java/org/elasticsearch/node/Node.java @@ -427,10 +427,10 @@ public class Node implements Closeable { .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); final IndicesService indicesService = - new IndicesService(settings, pluginsService, nodeEnvironment, xContentRegistry, analysisModule.getAnalysisRegistry(), - clusterModule.getIndexNameExpressionResolver(), indicesModule.getMapperRegistry(), namedWriteableRegistry, - threadPool, settingsModule.getIndexScopedSettings(), circuitBreakerService, bigArrays, - scriptModule.getScriptService(), client, metaStateService, engineFactoryProviders, indexStoreFactories); + new IndicesService(settings, pluginsService, nodeEnvironment, xContentRegistry, analysisModule.getAnalysisRegistry(), + clusterModule.getIndexNameExpressionResolver(), indicesModule.getMapperRegistry(), namedWriteableRegistry, + threadPool, settingsModule.getIndexScopedSettings(), circuitBreakerService, bigArrays, scriptModule.getScriptService(), + clusterService, client, metaStateService, engineFactoryProviders, indexStoreFactories); final AliasValidator aliasValidator = new AliasValidator(); diff --git a/server/src/test/java/org/elasticsearch/index/IndexModuleTests.java b/server/src/test/java/org/elasticsearch/index/IndexModuleTests.java index d052fa365be..7c8d7b902fb 100644 --- a/server/src/test/java/org/elasticsearch/index/IndexModuleTests.java +++ b/server/src/test/java/org/elasticsearch/index/IndexModuleTests.java @@ -150,7 +150,7 @@ public class IndexModuleTests extends ESTestCase { private IndexService newIndexService(IndexModule module) throws IOException { return module.newIndexService(CREATE_INDEX, nodeEnvironment, xContentRegistry(), deleter, circuitBreakerService, bigArrays, - threadPool, scriptService, null, indicesQueryCache, mapperRegistry, + threadPool, scriptService, clusterService, null, indicesQueryCache, mapperRegistry, new IndicesFieldDataCache(settings, listener), writableRegistry()); } diff --git a/server/src/test/java/org/elasticsearch/index/mapper/DateFieldTypeTests.java b/server/src/test/java/org/elasticsearch/index/mapper/DateFieldTypeTests.java index 479f4d7fc55..6ac59169ad9 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/DateFieldTypeTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/DateFieldTypeTests.java @@ -179,7 +179,7 @@ public class DateFieldTypeTests extends FieldTypeTestCase { QueryShardContext context = new QueryShardContext(0, new IndexSettings(IndexMetaData.builder("foo").settings(indexSettings).build(), indexSettings), BigArrays.NON_RECYCLING_INSTANCE, null, null, null, null, null, - xContentRegistry(), writableRegistry(), null, null, () -> nowInMillis, null); + xContentRegistry(), writableRegistry(), null, null, () -> nowInMillis, null, null); MappedFieldType ft = createDefaultFieldType(); ft.setName("field"); String date = "2015-10-12T14:10:55"; @@ -202,7 +202,7 @@ public class DateFieldTypeTests extends FieldTypeTestCase { QueryShardContext context = new QueryShardContext(0, new IndexSettings(IndexMetaData.builder("foo").settings(indexSettings).build(), indexSettings), BigArrays.NON_RECYCLING_INSTANCE, null, null, null, null, null, xContentRegistry(), writableRegistry(), - null, null, () -> nowInMillis, null); + null, null, () -> nowInMillis, null, null); MappedFieldType ft = createDefaultFieldType(); ft.setName("field"); String date1 = "2015-10-12T14:10:55"; diff --git a/server/src/test/java/org/elasticsearch/index/mapper/FieldNamesFieldTypeTests.java b/server/src/test/java/org/elasticsearch/index/mapper/FieldNamesFieldTypeTests.java index 9bbeecdfc8f..1a9460115f0 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/FieldNamesFieldTypeTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/FieldNamesFieldTypeTests.java @@ -68,7 +68,7 @@ public class FieldNamesFieldTypeTests extends FieldTypeTestCase { QueryShardContext queryShardContext = new QueryShardContext(0, indexSettings, BigArrays.NON_RECYCLING_INSTANCE, null, null, mapperService, - null, null, null, null, null, null, () -> 0L, null); + null, null, null, null, null, null, () -> 0L, null, null); fieldNamesFieldType.setEnabled(true); Query termQuery = fieldNamesFieldType.termQuery("field_name", queryShardContext); assertEquals(new TermQuery(new Term(FieldNamesFieldMapper.CONTENT_TYPE, "field_name")), termQuery); diff --git a/server/src/test/java/org/elasticsearch/index/mapper/IndexFieldTypeTests.java b/server/src/test/java/org/elasticsearch/index/mapper/IndexFieldTypeTests.java index 82f0edf24f4..11b365ff16e 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/IndexFieldTypeTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/IndexFieldTypeTests.java @@ -21,11 +21,14 @@ package org.elasticsearch.index.mapper; import org.apache.lucene.index.IndexOptions; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.search.MatchNoDocsQuery; -import org.elasticsearch.index.Index; +import org.elasticsearch.Version; +import org.elasticsearch.cluster.metadata.IndexMetaData; +import org.elasticsearch.common.regex.Regex; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.query.QueryShardContext; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; +import java.util.function.Predicate; public class IndexFieldTypeTests extends FieldTypeTestCase { @@ -62,12 +65,15 @@ public class IndexFieldTypeTests extends FieldTypeTestCase { } private QueryShardContext createContext() { - QueryShardContext context = mock(QueryShardContext.class); + IndexMetaData indexMetaData = IndexMetaData.builder("index") + .settings(Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)) + .numberOfShards(1) + .numberOfReplicas(0) + .build(); + IndexSettings indexSettings = new IndexSettings(indexMetaData, Settings.EMPTY); - Index index = new Index("index", "123"); - when(context.getFullyQualifiedIndex()).thenReturn(index); - when(context.index()).thenReturn(index); - - return context; + Predicate indexNameMatcher = pattern -> Regex.simpleMatch(pattern, "index"); + return new QueryShardContext(0, indexSettings, null, null, null, null, null, null, xContentRegistry(), writableRegistry(), + null, null, System::currentTimeMillis, null, indexNameMatcher); } } diff --git a/server/src/test/java/org/elasticsearch/index/mapper/RangeFieldTypeTests.java b/server/src/test/java/org/elasticsearch/index/mapper/RangeFieldTypeTests.java index 16fe2ceee8f..79ab18afbd5 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/RangeFieldTypeTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/RangeFieldTypeTests.java @@ -229,7 +229,7 @@ public class RangeFieldTypeTests extends FieldTypeTestCase { .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build(); IndexSettings idxSettings = IndexSettingsModule.newIndexSettings(randomAlphaOfLengthBetween(1, 10), indexSettings); return new QueryShardContext(0, idxSettings, BigArrays.NON_RECYCLING_INSTANCE, null, null, null, null, null, - xContentRegistry(), writableRegistry(), null, null, () -> nowInMillis, null); + xContentRegistry(), writableRegistry(), null, null, () -> nowInMillis, null, null); } public void testDateRangeQueryUsingMappingFormat() { diff --git a/server/src/test/java/org/elasticsearch/index/query/IntervalQueryBuilderTests.java b/server/src/test/java/org/elasticsearch/index/query/IntervalQueryBuilderTests.java index 379719f3616..4f2d9d217f9 100644 --- a/server/src/test/java/org/elasticsearch/index/query/IntervalQueryBuilderTests.java +++ b/server/src/test/java/org/elasticsearch/index/query/IntervalQueryBuilderTests.java @@ -371,7 +371,7 @@ public class IntervalQueryBuilderTests extends AbstractQueryTestCase mappedFieldType.fielddataBuilder(idxName).build(indexSettings, mappedFieldType, null, null, null), mapperService, null, null, NamedXContentRegistry.EMPTY, new NamedWriteableRegistry(Collections.emptyList()), - null, null, () -> nowInMillis, clusterAlias); + null, null, () -> nowInMillis, clusterAlias, null); } } diff --git a/server/src/test/java/org/elasticsearch/index/query/RangeQueryRewriteTests.java b/server/src/test/java/org/elasticsearch/index/query/RangeQueryRewriteTests.java index f4d7c90488f..83ab9c8e62b 100644 --- a/server/src/test/java/org/elasticsearch/index/query/RangeQueryRewriteTests.java +++ b/server/src/test/java/org/elasticsearch/index/query/RangeQueryRewriteTests.java @@ -41,7 +41,7 @@ public class RangeQueryRewriteTests extends ESSingleNodeTestCase { IndexReader reader = new MultiReader(); QueryRewriteContext context = new QueryShardContext(0, indexService.getIndexSettings(), BigArrays.NON_RECYCLING_INSTANCE, null, null, indexService.mapperService(), null, null, xContentRegistry(), writableRegistry(), - null, new IndexSearcher(reader), null, null); + null, new IndexSearcher(reader), null, null, null); RangeQueryBuilder range = new RangeQueryBuilder("foo"); assertEquals(Relation.DISJOINT, range.getRelation(context)); } @@ -57,9 +57,8 @@ public class RangeQueryRewriteTests extends ESSingleNodeTestCase { .endObject().endObject()); indexService.mapperService().merge("type", new CompressedXContent(mapping), MergeReason.MAPPING_UPDATE); - QueryRewriteContext context = new QueryShardContext(0, indexService.getIndexSettings(), BigArrays.NON_RECYCLING_INSTANCE, - null, null, indexService.mapperService(), null, null, - xContentRegistry(), writableRegistry(), null, null, null, null); + QueryRewriteContext context = new QueryShardContext(0, indexService.getIndexSettings(), null, null, null, + indexService.mapperService(), null, null, xContentRegistry(), writableRegistry(), null, null, null, null, null); RangeQueryBuilder range = new RangeQueryBuilder("foo"); // can't make assumptions on a missing reader, so it must return INTERSECT assertEquals(Relation.INTERSECTS, range.getRelation(context)); @@ -79,7 +78,7 @@ public class RangeQueryRewriteTests extends ESSingleNodeTestCase { IndexReader reader = new MultiReader(); QueryRewriteContext context = new QueryShardContext(0, indexService.getIndexSettings(), BigArrays.NON_RECYCLING_INSTANCE, null, null, indexService.mapperService(), null, null, xContentRegistry(), writableRegistry(), - null, new IndexSearcher(reader), null, null); + null, new IndexSearcher(reader), null, null, null); RangeQueryBuilder range = new RangeQueryBuilder("foo"); // no values -> DISJOINT assertEquals(Relation.DISJOINT, range.getRelation(context)); diff --git a/server/src/test/java/org/elasticsearch/index/query/SearchIndexNameMatcherTests.java b/server/src/test/java/org/elasticsearch/index/query/SearchIndexNameMatcherTests.java new file mode 100644 index 00000000000..a796586bcf5 --- /dev/null +++ b/server/src/test/java/org/elasticsearch/index/query/SearchIndexNameMatcherTests.java @@ -0,0 +1,90 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.index.query; + +import org.elasticsearch.Version; +import org.elasticsearch.cluster.ClusterName; +import org.elasticsearch.cluster.ClusterState; +import org.elasticsearch.cluster.metadata.AliasMetaData; +import org.elasticsearch.cluster.metadata.IndexMetaData; +import org.elasticsearch.cluster.metadata.MetaData; +import org.elasticsearch.cluster.service.ClusterService; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.test.ESTestCase; +import org.junit.Before; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class SearchIndexNameMatcherTests extends ESTestCase { + private SearchIndexNameMatcher matcher; + private SearchIndexNameMatcher remoteMatcher; + + @Before + public void setUpMatchers() { + MetaData.Builder metaDataBuilder = MetaData.builder() + .put(indexBuilder("index1").putAlias(AliasMetaData.builder("alias"))) + .put(indexBuilder("index2").putAlias(AliasMetaData.builder("alias"))) + .put(indexBuilder("index3")); + ClusterState state = ClusterState.builder(new ClusterName("_name")).metaData(metaDataBuilder).build(); + + ClusterService clusterService = mock(ClusterService.class); + when(clusterService.state()).thenReturn(state); + + matcher = new SearchIndexNameMatcher("index1", "", clusterService); + remoteMatcher = new SearchIndexNameMatcher("index1", "cluster", clusterService); + } + + private static IndexMetaData.Builder indexBuilder(String index) { + Settings.Builder settings = settings(Version.CURRENT). + put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1) + .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0); + return IndexMetaData.builder(index).settings(settings); + } + + public void testLocalIndex() { + assertTrue(matcher.test("index1")); + assertTrue(matcher.test("ind*x1")); + assertFalse(matcher.test("index2")); + + assertTrue(matcher.test("alias")); + assertTrue(matcher.test("*lias")); + + assertFalse(matcher.test("cluster:index1")); + } + + public void testRemoteIndex() { + assertTrue(remoteMatcher.test("cluster:index1")); + assertTrue(remoteMatcher.test("cluster:ind*x1")); + assertTrue(remoteMatcher.test("*luster:ind*x1")); + assertFalse(remoteMatcher.test("cluster:index2")); + + assertTrue(remoteMatcher.test("cluster:alias")); + assertTrue(remoteMatcher.test("cluster:*lias")); + + assertFalse(remoteMatcher.test("index1")); + assertFalse(remoteMatcher.test("alias")); + + assertFalse(remoteMatcher.test("*index1")); + assertFalse(remoteMatcher.test("*alias")); + assertFalse(remoteMatcher.test("cluster*")); + assertFalse(remoteMatcher.test("cluster*index1")); + } +} diff --git a/server/src/test/java/org/elasticsearch/index/query/SimpleQueryStringBuilderTests.java b/server/src/test/java/org/elasticsearch/index/query/SimpleQueryStringBuilderTests.java index 78a7ca35eae..bad1a6c7045 100644 --- a/server/src/test/java/org/elasticsearch/index/query/SimpleQueryStringBuilderTests.java +++ b/server/src/test/java/org/elasticsearch/index/query/SimpleQueryStringBuilderTests.java @@ -27,7 +27,6 @@ import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.BoostQuery; import org.apache.lucene.search.DisjunctionMaxQuery; import org.apache.lucene.search.FuzzyQuery; -import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.search.MatchNoDocsQuery; import org.apache.lucene.search.PhraseQuery; import org.apache.lucene.search.PrefixQuery; @@ -416,15 +415,6 @@ public class SimpleQueryStringBuilderTests extends AbstractQueryTestCase now, null); + null, null, () -> now, null, null); DateFormatter formatter = DateFormatter.forPattern("dateOptionalTime"); DocValueFormat format = new DocValueFormat.DateTime(formatter, ZoneOffset.UTC, DateFieldMapper.Resolution.MILLISECONDS); diff --git a/server/src/test/java/org/elasticsearch/search/aggregations/metrics/ScriptedMetricAggregatorTests.java b/server/src/test/java/org/elasticsearch/search/aggregations/metrics/ScriptedMetricAggregatorTests.java index 7203b5dd443..9d0d1d69f02 100644 --- a/server/src/test/java/org/elasticsearch/search/aggregations/metrics/ScriptedMetricAggregatorTests.java +++ b/server/src/test/java/org/elasticsearch/search/aggregations/metrics/ScriptedMetricAggregatorTests.java @@ -426,6 +426,6 @@ public class ScriptedMetricAggregatorTests extends AggregatorTestCase { Map engines = Collections.singletonMap(scriptEngine.getType(), scriptEngine); ScriptService scriptService = new ScriptService(Settings.EMPTY, engines, ScriptModule.CORE_CONTEXTS); return new QueryShardContext(0, indexSettings, BigArrays.NON_RECYCLING_INSTANCE, null, null, mapperService, null, scriptService, - xContentRegistry(), writableRegistry(), null, null, System::currentTimeMillis, null); + xContentRegistry(), writableRegistry(), null, null, System::currentTimeMillis, null, null); } } diff --git a/server/src/test/java/org/elasticsearch/search/fetch/subphase/highlight/HighlightBuilderTests.java b/server/src/test/java/org/elasticsearch/search/fetch/subphase/highlight/HighlightBuilderTests.java index 65d2e92555c..a1f669558a5 100644 --- a/server/src/test/java/org/elasticsearch/search/fetch/subphase/highlight/HighlightBuilderTests.java +++ b/server/src/test/java/org/elasticsearch/search/fetch/subphase/highlight/HighlightBuilderTests.java @@ -280,7 +280,7 @@ public class HighlightBuilderTests extends ESTestCase { // shard context will only need indicesQueriesRegistry for building Query objects nested in highlighter QueryShardContext mockShardContext = new QueryShardContext(0, idxSettings, BigArrays.NON_RECYCLING_INSTANCE, null, null, null, null, null, xContentRegistry(), namedWriteableRegistry, - null, null, System::currentTimeMillis, null) { + null, null, System::currentTimeMillis, null, null) { @Override public MappedFieldType fieldMapper(String name) { TextFieldMapper.Builder builder = new TextFieldMapper.Builder(name); diff --git a/server/src/test/java/org/elasticsearch/search/rescore/QueryRescorerBuilderTests.java b/server/src/test/java/org/elasticsearch/search/rescore/QueryRescorerBuilderTests.java index 995cfa3b1c9..accf23a9644 100644 --- a/server/src/test/java/org/elasticsearch/search/rescore/QueryRescorerBuilderTests.java +++ b/server/src/test/java/org/elasticsearch/search/rescore/QueryRescorerBuilderTests.java @@ -144,7 +144,7 @@ public class QueryRescorerBuilderTests extends ESTestCase { // shard context will only need indicesQueriesRegistry for building Query objects nested in query rescorer QueryShardContext mockShardContext = new QueryShardContext(0, idxSettings, BigArrays.NON_RECYCLING_INSTANCE, null, null, null, null, null, - xContentRegistry(), namedWriteableRegistry, null, null, () -> nowInMillis, null) { + xContentRegistry(), namedWriteableRegistry, null, null, () -> nowInMillis, null, null) { @Override public MappedFieldType fieldMapper(String name) { TextFieldMapper.Builder builder = new TextFieldMapper.Builder(name); @@ -188,7 +188,7 @@ public class QueryRescorerBuilderTests extends ESTestCase { // shard context will only need indicesQueriesRegistry for building Query objects nested in query rescorer QueryShardContext mockShardContext = new QueryShardContext(0, idxSettings, BigArrays.NON_RECYCLING_INSTANCE, null, null, null, null, null, - xContentRegistry(), namedWriteableRegistry, null, null, () -> nowInMillis, null) { + xContentRegistry(), namedWriteableRegistry, null, null, () -> nowInMillis, null, null) { @Override public MappedFieldType fieldMapper(String name) { TextFieldMapper.Builder builder = new TextFieldMapper.Builder(name); diff --git a/server/src/test/java/org/elasticsearch/search/sort/AbstractSortTestCase.java b/server/src/test/java/org/elasticsearch/search/sort/AbstractSortTestCase.java index a09cb4b0dfa..28ca23df124 100644 --- a/server/src/test/java/org/elasticsearch/search/sort/AbstractSortTestCase.java +++ b/server/src/test/java/org/elasticsearch/search/sort/AbstractSortTestCase.java @@ -192,7 +192,7 @@ public abstract class AbstractSortTestCase> extends EST return builder.build(idxSettings, fieldType, new IndexFieldDataCache.None(), null, null); }; return new QueryShardContext(0, idxSettings, BigArrays.NON_RECYCLING_INSTANCE, bitsetFilterCache, indexFieldDataLookup, - null, null, scriptService, xContentRegistry(), namedWriteableRegistry, null, null, () -> randomNonNegativeLong(), null) { + null, null, scriptService, xContentRegistry(), namedWriteableRegistry, null, null, () -> randomNonNegativeLong(), null, null) { @Override public MappedFieldType fieldMapper(String name) { diff --git a/server/src/test/java/org/elasticsearch/search/suggest/AbstractSuggestionBuilderTestCase.java b/server/src/test/java/org/elasticsearch/search/suggest/AbstractSuggestionBuilderTestCase.java index d0289c7fa97..f60c3f07740 100644 --- a/server/src/test/java/org/elasticsearch/search/suggest/AbstractSuggestionBuilderTestCase.java +++ b/server/src/test/java/org/elasticsearch/search/suggest/AbstractSuggestionBuilderTestCase.java @@ -181,7 +181,7 @@ public abstract class AbstractSuggestionBuilderTestCase nowInMillis, null); + namedWriteableRegistry, this.client, searcher, () -> nowInMillis, null, null); } ScriptModule createScriptModule(List scriptPlugins) { diff --git a/test/framework/src/test/java/org/elasticsearch/search/MockSearchServiceTests.java b/test/framework/src/test/java/org/elasticsearch/search/MockSearchServiceTests.java index 668495f6f70..8a8842487f1 100644 --- a/test/framework/src/test/java/org/elasticsearch/search/MockSearchServiceTests.java +++ b/test/framework/src/test/java/org/elasticsearch/search/MockSearchServiceTests.java @@ -43,7 +43,7 @@ public class MockSearchServiceTests extends ESTestCase { final long nowInMillis = randomNonNegativeLong(); SearchContext s = new TestSearchContext(new QueryShardContext(0, new IndexSettings(EMPTY_INDEX_METADATA, Settings.EMPTY), BigArrays.NON_RECYCLING_INSTANCE, null, null, null, null, null, - xContentRegistry(), writableRegistry(), null, null, () -> nowInMillis, null)) { + xContentRegistry(), writableRegistry(), null, null, () -> nowInMillis, null, null)) { @Override public SearchShardTarget shardTarget() { diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/accesscontrol/DocumentSubsetBitsetCacheTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/accesscontrol/DocumentSubsetBitsetCacheTests.java index f78b9c2aa6f..a50c39d4e6a 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/accesscontrol/DocumentSubsetBitsetCacheTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/accesscontrol/DocumentSubsetBitsetCacheTests.java @@ -241,7 +241,7 @@ public class DocumentSubsetBitsetCacheTests extends ESTestCase { final QueryShardContext context = new QueryShardContext(shardId.id(), indexSettings, BigArrays.NON_RECYCLING_INSTANCE, null, null, mapperService, null, null, xContentRegistry(), writableRegistry(), - client, new IndexSearcher(directoryReader), () -> nowInMillis, null); + client, new IndexSearcher(directoryReader), () -> nowInMillis, null, null); body.accept(context, leaf); } } diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/accesscontrol/SecurityIndexReaderWrapperIntegrationTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/accesscontrol/SecurityIndexReaderWrapperIntegrationTests.java index 8214d327491..ca49e4ae4a3 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/accesscontrol/SecurityIndexReaderWrapperIntegrationTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/accesscontrol/SecurityIndexReaderWrapperIntegrationTests.java @@ -85,7 +85,7 @@ public class SecurityIndexReaderWrapperIntegrationTests extends AbstractBuilderT final long nowInMillis = randomNonNegativeLong(); QueryShardContext realQueryShardContext = new QueryShardContext(shardId.id(), indexSettings, BigArrays.NON_RECYCLING_INSTANCE, null, null, mapperService, null, null, xContentRegistry(), writableRegistry(), - client, null, () -> nowInMillis, null); + client, null, () -> nowInMillis, null, null); QueryShardContext queryShardContext = spy(realQueryShardContext); DocumentSubsetBitsetCache bitsetCache = new DocumentSubsetBitsetCache(Settings.EMPTY); XPackLicenseState licenseState = mock(XPackLicenseState.class); @@ -200,7 +200,7 @@ public class SecurityIndexReaderWrapperIntegrationTests extends AbstractBuilderT final long nowInMillis = randomNonNegativeLong(); QueryShardContext realQueryShardContext = new QueryShardContext(shardId.id(), indexSettings, BigArrays.NON_RECYCLING_INSTANCE, null, null, mapperService, null, null, xContentRegistry(), writableRegistry(), - client, null, () -> nowInMillis, null); + client, null, () -> nowInMillis, null, null); QueryShardContext queryShardContext = spy(realQueryShardContext); DocumentSubsetBitsetCache bitsetCache = new DocumentSubsetBitsetCache(Settings.EMPTY); diff --git a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/job/RollupIndexerIndexingTests.java b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/job/RollupIndexerIndexingTests.java index 7f5a8232a6d..492d24b88f0 100644 --- a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/job/RollupIndexerIndexingTests.java +++ b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/job/RollupIndexerIndexingTests.java @@ -93,7 +93,7 @@ public class RollupIndexerIndexingTests extends AggregatorTestCase { settings = createIndexSettings(); queryShardContext = new QueryShardContext(0, settings, BigArrays.NON_RECYCLING_INSTANCE, null, null, null, null, null, - null, null, null, null, () -> 0L, null); + null, null, null, null, () -> 0L, null, null); } public void testSimpleDateHisto() throws Exception {