Skip to content

Commit

Permalink
Remove registerQueryParser
Browse files Browse the repository at this point in the history
We've fully cut over to registerQuery!
  • Loading branch information
nik9000 committed Apr 8, 2016
1 parent 0d8e399 commit d349de7
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions core/src/main/java/org/elasticsearch/search/SearchModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -335,28 +335,16 @@ private void registerValueFormat(String name, Writeable.Reader<? extends DocValu
*/
public <QB extends QueryBuilder<QB>> void registerQuery(Writeable.Reader<QB> reader, QueryParser<QB> queryParser,
ParseField queryName) {
innerRegisterQueryParser(queryParser, queryName);
namedWriteableRegistry.register(QueryBuilder.class, queryName.getPreferredName(), reader);
}

/**
* Register a query via its parser's prototype.
* TODO remove this in favor of registerQuery and merge innerRegisterQueryParser into registerQuery
*/
public void registerQueryParser(QueryParser<?> queryParser, ParseField queryName) {
innerRegisterQueryParser(queryParser, queryName);
namedWriteableRegistry.registerPrototype(QueryBuilder.class, queryParser.getBuilderPrototype());
}

private <QB extends QueryBuilder<QB>> void innerRegisterQueryParser(QueryParser<QB> parser, ParseField queryName) {
Tuple<ParseField, QueryParser<?>> parseFieldQueryParserTuple = new Tuple<>(queryName, parser);
Tuple<ParseField, QueryParser<?>> parseFieldQueryParserTuple = new Tuple<>(queryName, queryParser);
for (String name: queryName.getAllNamesIncludedDeprecated()) {
Tuple<ParseField, QueryParser<?>> previousValue = queryParsers.putIfAbsent(name, parseFieldQueryParserTuple);
if (previousValue != null) {
throw new IllegalArgumentException("Query parser [" + previousValue.v2() + "] already registered for name [" +
name + "] while trying to register [" + parser + "]");
name + "] while trying to register [" + queryParser + "]");
}
}

namedWriteableRegistry.register(QueryBuilder.class, queryName.getPreferredName(), reader);
}

Set<String> getRegisteredQueries() {
Expand Down

0 comments on commit d349de7

Please sign in to comment.