Skip to content

Commit 99e4723

Browse files
committed
Remove IndicesQueriesRegistry
Replace it with `XContentParser#namedObject`.
1 parent 4f43d90 commit 99e4723

File tree

67 files changed

+168
-442
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+168
-442
lines changed

core/src/main/java/org/elasticsearch/index/IndexModule.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
import org.elasticsearch.indices.breaker.CircuitBreakerService;
4949
import org.elasticsearch.indices.fielddata.cache.IndicesFieldDataCache;
5050
import org.elasticsearch.indices.mapper.MapperRegistry;
51-
import org.elasticsearch.indices.query.IndicesQueriesRegistry;
5251
import org.elasticsearch.script.ScriptService;
5352
import org.elasticsearch.threadpool.ThreadPool;
5453

@@ -327,7 +326,6 @@ public IndexService newIndexService(
327326
BigArrays bigArrays,
328327
ThreadPool threadPool,
329328
ScriptService scriptService,
330-
IndicesQueriesRegistry indicesQueriesRegistry,
331329
ClusterService clusterService,
332330
Client client,
333331
IndicesQueryCache indicesQueryCache,
@@ -366,7 +364,7 @@ public IndexService newIndexService(
366364
}
367365
return new IndexService(indexSettings, environment, xContentRegistry, new SimilarityService(indexSettings, similarities),
368366
shardStoreDeleter, analysisRegistry, engineFactory.get(), circuitBreakerService, bigArrays, threadPool, scriptService,
369-
indicesQueriesRegistry, clusterService, client, queryCache, store, eventListener, searcherWrapperFactory, mapperRegistry,
367+
clusterService, client, queryCache, store, eventListener, searcherWrapperFactory, mapperRegistry,
370368
indicesFieldDataCache, globalCheckpointSyncer, searchOperationListeners, indexOperationListeners);
371369
}
372370

core/src/main/java/org/elasticsearch/index/IndexService.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@
6868
import org.elasticsearch.indices.cluster.IndicesClusterStateService;
6969
import org.elasticsearch.indices.fielddata.cache.IndicesFieldDataCache;
7070
import org.elasticsearch.indices.mapper.MapperRegistry;
71-
import org.elasticsearch.indices.query.IndicesQueriesRegistry;
7271
import org.elasticsearch.script.ScriptService;
7372
import org.elasticsearch.threadpool.ThreadPool;
7473

@@ -120,7 +119,6 @@ public class IndexService extends AbstractIndexComponent implements IndicesClust
120119
private final BigArrays bigArrays;
121120
private final AsyncGlobalCheckpointTask globalCheckpointTask;
122121
private final ScriptService scriptService;
123-
private final IndicesQueriesRegistry queryRegistry;
124122
private final ClusterService clusterService;
125123
private final Client client;
126124

@@ -134,7 +132,6 @@ public IndexService(IndexSettings indexSettings, NodeEnvironment nodeEnv,
134132
BigArrays bigArrays,
135133
ThreadPool threadPool,
136134
ScriptService scriptService,
137-
IndicesQueriesRegistry queryRegistry,
138135
ClusterService clusterService,
139136
Client client,
140137
QueryCache queryCache,
@@ -162,7 +159,6 @@ public IndexService(IndexSettings indexSettings, NodeEnvironment nodeEnv,
162159
this.bigArrays = bigArrays;
163160
this.threadPool = threadPool;
164161
this.scriptService = scriptService;
165-
this.queryRegistry = queryRegistry;
166162
this.clusterService = clusterService;
167163
this.client = client;
168164
this.eventListener = eventListener;
@@ -478,7 +474,7 @@ public IndexSettings getIndexSettings() {
478474
public QueryShardContext newQueryShardContext(int shardId, IndexReader indexReader, LongSupplier nowInMillis) {
479475
return new QueryShardContext(
480476
shardId, indexSettings, indexCache.bitsetFilterCache(), indexFieldData, mapperService(),
481-
similarityService(), scriptService, xContentRegistry, queryRegistry,
477+
similarityService(), scriptService, xContentRegistry,
482478
client, indexReader,
483479
nowInMillis);
484480
}

core/src/main/java/org/elasticsearch/index/query/QueryParseContext.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import org.elasticsearch.common.xcontent.NamedXContentRegistry.UnknownNamedObjectException;
2727
import org.elasticsearch.common.xcontent.XContentLocation;
2828
import org.elasticsearch.common.xcontent.XContentParser;
29-
import org.elasticsearch.indices.query.IndicesQueriesRegistry;
3029
import org.elasticsearch.script.Script;
3130

3231
import java.io.IOException;
@@ -38,17 +37,14 @@ public class QueryParseContext implements ParseFieldMatcherSupplier {
3837
private static final ParseField CACHE_KEY = new ParseField("_cache_key").withAllDeprecated("Filters are always used as cache keys");
3938

4039
private final XContentParser parser;
41-
private final IndicesQueriesRegistry indicesQueriesRegistry;
4240
private final ParseFieldMatcher parseFieldMatcher;
4341
private final String defaultScriptLanguage;
4442

45-
public QueryParseContext(IndicesQueriesRegistry registry, XContentParser parser, ParseFieldMatcher parseFieldMatcher) {
46-
this(Script.DEFAULT_SCRIPT_LANG, registry, parser, parseFieldMatcher);
43+
public QueryParseContext(XContentParser parser, ParseFieldMatcher parseFieldMatcher) {
44+
this(Script.DEFAULT_SCRIPT_LANG, parser, parseFieldMatcher);
4745
}
4846

49-
public QueryParseContext(String defaultScriptLanguage, IndicesQueriesRegistry registry, XContentParser parser,
50-
ParseFieldMatcher parseFieldMatcher) {
51-
this.indicesQueriesRegistry = Objects.requireNonNull(registry, "indices queries registry cannot be null");
47+
public QueryParseContext(String defaultScriptLanguage, XContentParser parser, ParseFieldMatcher parseFieldMatcher) {
5248
this.parser = Objects.requireNonNull(parser, "parser cannot be null");
5349
this.parseFieldMatcher = Objects.requireNonNull(parseFieldMatcher, "parse field matcher cannot be null");
5450
this.defaultScriptLanguage = defaultScriptLanguage;
@@ -112,8 +108,9 @@ public QueryBuilder parseInnerQueryBuilder() throws IOException {
112108
result = parser.namedObject(QueryBuilder.class, queryName, this);
113109
} catch (UnknownNamedObjectException e) {
114110
// Preserve the error message from 5.0 until we have a compellingly better message so we don't break BWC.
111+
// This intentionally doesn't include the causing exception because that'd change the "root_cause" of any unknown query errors
115112
throw new ParsingException(new XContentLocation(e.getLineNumber(), e.getColumnNumber()),
116-
"no [query] registered for [" + e.getName() + "]", e);
113+
"no [query] registered for [" + e.getName() + "]");
117114
}
118115
//end_object of the specific query (e.g. match, multi_match etc.) element
119116
if (parser.currentToken() != XContentParser.Token.END_OBJECT) {

core/src/main/java/org/elasticsearch/index/query/QueryRewriteContext.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.elasticsearch.common.xcontent.XContentParser;
2828
import org.elasticsearch.index.IndexSettings;
2929
import org.elasticsearch.index.mapper.MapperService;
30-
import org.elasticsearch.indices.query.IndicesQueriesRegistry;
3130
import org.elasticsearch.script.ExecutableScript;
3231
import org.elasticsearch.script.Script;
3332
import org.elasticsearch.script.ScriptContext;
@@ -43,19 +42,17 @@ public class QueryRewriteContext implements ParseFieldMatcherSupplier {
4342
protected final ScriptService scriptService;
4443
protected final IndexSettings indexSettings;
4544
private final NamedXContentRegistry xContentRegistry;
46-
protected final IndicesQueriesRegistry indicesQueriesRegistry;
4745
protected final Client client;
4846
protected final IndexReader reader;
4947
protected final LongSupplier nowInMillis;
5048

5149
public QueryRewriteContext(IndexSettings indexSettings, MapperService mapperService, ScriptService scriptService,
52-
NamedXContentRegistry xContentRegistry, IndicesQueriesRegistry indicesQueriesRegistry, Client client, IndexReader reader,
50+
NamedXContentRegistry xContentRegistry, Client client, IndexReader reader,
5351
LongSupplier nowInMillis) {
5452
this.mapperService = mapperService;
5553
this.scriptService = scriptService;
5654
this.indexSettings = indexSettings;
5755
this.xContentRegistry = xContentRegistry;
58-
this.indicesQueriesRegistry = indicesQueriesRegistry;
5956
this.client = client;
6057
this.reader = reader;
6158
this.nowInMillis = nowInMillis;
@@ -107,7 +104,7 @@ public NamedXContentRegistry getXContentRegistry() {
107104
* are configured in the index settings. The default script language will always default to Painless.
108105
*/
109106
public QueryParseContext newParseContext(XContentParser parser) {
110-
return new QueryParseContext(indicesQueriesRegistry, parser, indexSettings.getParseFieldMatcher());
107+
return new QueryParseContext(parser, indexSettings.getParseFieldMatcher());
111108
}
112109

113110
public long nowInMillis() {

core/src/main/java/org/elasticsearch/index/query/QueryShardContext.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
import org.elasticsearch.index.mapper.TextFieldMapper;
4949
import org.elasticsearch.index.query.support.NestedScope;
5050
import org.elasticsearch.index.similarity.SimilarityService;
51-
import org.elasticsearch.indices.query.IndicesQueriesRegistry;
5251
import org.elasticsearch.script.CompiledScript;
5352
import org.elasticsearch.script.ExecutableScript;
5453
import org.elasticsearch.script.Script;
@@ -92,32 +91,30 @@ public String[] getTypes() {
9291

9392
private final Map<String, Query> namedQueries = new HashMap<>();
9493
private final MapperQueryParser queryParser = new MapperQueryParser(this);
95-
private final IndicesQueriesRegistry indicesQueriesRegistry;
9694
private boolean allowUnmappedFields;
9795
private boolean mapUnmappedFieldAsString;
9896
private NestedScope nestedScope;
9997
private boolean isFilter;
10098

10199
public QueryShardContext(int shardId, IndexSettings indexSettings, BitsetFilterCache bitsetFilterCache,
102100
IndexFieldDataService indexFieldDataService, MapperService mapperService, SimilarityService similarityService,
103-
ScriptService scriptService, NamedXContentRegistry xContentRegistry, IndicesQueriesRegistry indicesQueriesRegistry,
101+
ScriptService scriptService, NamedXContentRegistry xContentRegistry,
104102
Client client, IndexReader reader, LongSupplier nowInMillis) {
105-
super(indexSettings, mapperService, scriptService, xContentRegistry, indicesQueriesRegistry, client, reader, nowInMillis);
103+
super(indexSettings, mapperService, scriptService, xContentRegistry, client, reader, nowInMillis);
106104
this.shardId = shardId;
107105
this.indexSettings = indexSettings;
108106
this.similarityService = similarityService;
109107
this.mapperService = mapperService;
110108
this.bitsetFilterCache = bitsetFilterCache;
111109
this.indexFieldDataService = indexFieldDataService;
112110
this.allowUnmappedFields = indexSettings.isDefaultAllowUnmappedFields();
113-
this.indicesQueriesRegistry = indicesQueriesRegistry;
114111
this.nestedScope = new NestedScope();
115112

116113
}
117114

118115
public QueryShardContext(QueryShardContext source) {
119116
this(source.shardId, source.indexSettings, source.bitsetFilterCache, source.indexFieldDataService, source.mapperService,
120-
source.similarityService, source.scriptService, source.getXContentRegistry(), source.indicesQueriesRegistry, source.client,
117+
source.similarityService, source.scriptService, source.getXContentRegistry(), source.client,
121118
source.reader, source.nowInMillis);
122119
this.types = source.getTypes();
123120
}

core/src/main/java/org/elasticsearch/indices/IndicesService.java

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919

2020
package org.elasticsearch.indices;
2121

22-
import com.carrotsearch.hppc.cursors.ObjectCursor;
23-
2422
import org.apache.logging.log4j.Logger;
2523
import org.apache.logging.log4j.message.ParameterizedMessage;
2624
import org.apache.lucene.index.DirectoryReader;
@@ -41,7 +39,6 @@
4139
import org.elasticsearch.cluster.ClusterState;
4240
import org.elasticsearch.cluster.metadata.IndexMetaData;
4341
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
44-
import org.elasticsearch.cluster.metadata.MappingMetaData;
4542
import org.elasticsearch.cluster.routing.RecoverySource;
4643
import org.elasticsearch.cluster.routing.ShardRouting;
4744
import org.elasticsearch.cluster.service.ClusterService;
@@ -106,7 +103,6 @@
106103
import org.elasticsearch.indices.cluster.IndicesClusterStateService;
107104
import org.elasticsearch.indices.fielddata.cache.IndicesFieldDataCache;
108105
import org.elasticsearch.indices.mapper.MapperRegistry;
109-
import org.elasticsearch.indices.query.IndicesQueriesRegistry;
110106
import org.elasticsearch.indices.recovery.PeerRecoveryTargetService;
111107
import org.elasticsearch.indices.recovery.RecoveryState;
112108
import org.elasticsearch.plugins.PluginsService;
@@ -156,7 +152,6 @@ public class IndicesService extends AbstractLifecycleComponent
156152
private final NamedXContentRegistry xContentRegistry;
157153
private final TimeValue shardsClosedTimeout;
158154
private final AnalysisRegistry analysisRegistry;
159-
private final IndicesQueriesRegistry indicesQueriesRegistry;
160155
private final IndexNameExpressionResolver indexNameExpressionResolver;
161156
private final IndexScopedSettings indexScopeSetting;
162157
private final IndicesFieldDataCache indicesFieldDataCache;
@@ -187,7 +182,7 @@ protected void doStart() {
187182

188183
public IndicesService(Settings settings, PluginsService pluginsService, NodeEnvironment nodeEnv, NamedXContentRegistry xContentRegistry,
189184
ClusterSettings clusterSettings, AnalysisRegistry analysisRegistry,
190-
IndicesQueriesRegistry indicesQueriesRegistry, IndexNameExpressionResolver indexNameExpressionResolver,
185+
IndexNameExpressionResolver indexNameExpressionResolver,
191186
MapperRegistry mapperRegistry, NamedWriteableRegistry namedWriteableRegistry,
192187
ThreadPool threadPool, IndexScopedSettings indexScopedSettings, CircuitBreakerService circuitBreakerService,
193188
BigArrays bigArrays, ScriptService scriptService, ClusterService clusterService, Client client,
@@ -199,7 +194,6 @@ public IndicesService(Settings settings, PluginsService pluginsService, NodeEnvi
199194
this.xContentRegistry = xContentRegistry;
200195
this.shardsClosedTimeout = settings.getAsTime(INDICES_SHARDS_CLOSED_TIMEOUT, new TimeValue(1, TimeUnit.DAYS));
201196
this.analysisRegistry = analysisRegistry;
202-
this.indicesQueriesRegistry = indicesQueriesRegistry;
203197
this.indexNameExpressionResolver = indexNameExpressionResolver;
204198
this.indicesRequestCache = new IndicesRequestCache(settings);
205199
this.indicesQueryCache = new IndicesQueryCache(settings);
@@ -451,7 +445,6 @@ private synchronized IndexService createIndexService(final String reason,
451445
bigArrays,
452446
threadPool,
453447
scriptService,
454-
indicesQueriesRegistry,
455448
clusterService,
456449
client,
457450
indicesQueryCache,
@@ -1017,13 +1010,6 @@ public boolean hasUncompletedPendingDeletes() {
10171010
return numUncompletedDeletes.get() > 0;
10181011
}
10191012

1020-
/**
1021-
* Returns this nodes {@link IndicesQueriesRegistry}
1022-
*/
1023-
public IndicesQueriesRegistry getIndicesQueryRegistry() {
1024-
return indicesQueriesRegistry;
1025-
}
1026-
10271013
public AnalysisRegistry getAnalysis() {
10281014
return analysisRegistry;
10291015
}
@@ -1268,7 +1254,7 @@ public AliasFilter buildAliasFilter(ClusterState state, String index, String...
12681254
* of dependencies we pass in a function that can perform the parsing. */
12691255
ShardSearchRequest.FilterParser filterParser = bytes -> {
12701256
try (XContentParser parser = XContentFactory.xContent(bytes).createParser(xContentRegistry, bytes)) {
1271-
return new QueryParseContext(indicesQueriesRegistry, parser, new ParseFieldMatcher(settings)).parseInnerQueryBuilder();
1257+
return new QueryParseContext(parser, new ParseFieldMatcher(settings)).parseInnerQueryBuilder();
12721258
}
12731259
};
12741260
String[] aliases = indexNameExpressionResolver.filteringAliases(state, index, expressions);

core/src/main/java/org/elasticsearch/indices/query/IndicesQueriesRegistry.java

Lines changed: 0 additions & 32 deletions
This file was deleted.

core/src/main/java/org/elasticsearch/node/Node.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@
9494
import org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService;
9595
import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
9696
import org.elasticsearch.indices.cluster.IndicesClusterStateService;
97-
import org.elasticsearch.indices.query.IndicesQueriesRegistry;
9897
import org.elasticsearch.indices.recovery.PeerRecoverySourceService;
9998
import org.elasticsearch.indices.recovery.PeerRecoveryTargetService;
10099
import org.elasticsearch.indices.recovery.RecoverySettings;
@@ -372,7 +371,7 @@ protected Node(final Environment environment, Collection<Class<? extends Plugin>
372371
).flatMap(Function.identity()).collect(toList()));
373372
final MetaStateService metaStateService = new MetaStateService(settings, nodeEnvironment);
374373
final IndicesService indicesService = new IndicesService(settings, pluginsService, nodeEnvironment, xContentRegistry,
375-
settingsModule.getClusterSettings(), analysisModule.getAnalysisRegistry(), searchModule.getQueryParserRegistry(),
374+
settingsModule.getClusterSettings(), analysisModule.getAnalysisRegistry(),
376375
clusterModule.getIndexNameExpressionResolver(), indicesModule.getMapperRegistry(), namedWriteableRegistry,
377376
threadPool, settingsModule.getIndexScopedSettings(), circuitBreakerService, bigArrays, scriptModule.getScriptService(),
378377
clusterService, client, metaStateService);
@@ -410,7 +409,6 @@ protected Node(final Environment environment, Collection<Class<? extends Plugin>
410409
final DiscoveryModule discoveryModule = new DiscoveryModule(this.settings, threadPool, transportService,
411410
networkService, clusterService, pluginsService.filterPlugins(DiscoveryPlugin.class));
412411
modules.add(b -> {
413-
b.bind(IndicesQueriesRegistry.class).toInstance(searchModule.getQueryParserRegistry());
414412
b.bind(SearchRequestParsers.class).toInstance(searchModule.getSearchRequestParsers());
415413
b.bind(SearchExtRegistry.class).toInstance(searchModule.getSearchExtRegistry());
416414
b.bind(NamedXContentRegistry.class).toInstance(xContentRegistry);

core/src/main/java/org/elasticsearch/rest/action/RestActions.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import org.elasticsearch.index.query.QueryBuilders;
3737
import org.elasticsearch.index.query.QueryParseContext;
3838
import org.elasticsearch.index.query.QueryStringQueryBuilder;
39-
import org.elasticsearch.indices.query.IndicesQueriesRegistry;
4039
import org.elasticsearch.rest.BytesRestResponse;
4140
import org.elasticsearch.rest.RestChannel;
4241
import org.elasticsearch.rest.RestRequest;
@@ -195,9 +194,9 @@ public static QueryBuilder urlParamsToQueryBuilder(RestRequest request) {
195194
return queryBuilder;
196195
}
197196

198-
public static QueryBuilder getQueryContent(XContentParser requestParser, IndicesQueriesRegistry indicesQueriesRegistry,
199-
ParseFieldMatcher parseFieldMatcher) {
200-
QueryParseContext context = new QueryParseContext(indicesQueriesRegistry, requestParser, parseFieldMatcher);
197+
public static QueryBuilder getQueryContent(XContentParser requestParser, ParseFieldMatcher parseFieldMatcher) {
198+
// NOCOMMIT it is very close to time to remove this
199+
QueryParseContext context = new QueryParseContext(requestParser, parseFieldMatcher);
201200
return context.parseTopLevelQueryBuilder();
202201
}
203202

0 commit comments

Comments
 (0)