Remove registerQueryParser
We've fully cut over to registerQuery!
This commit is contained in:
parent
0d8e399781
commit
d349de71aa
|
@ -335,28 +335,16 @@ public class SearchModule extends AbstractModule {
|
||||||
*/
|
*/
|
||||||
public <QB extends QueryBuilder<QB>> void registerQuery(Writeable.Reader<QB> reader, QueryParser<QB> queryParser,
|
public <QB extends QueryBuilder<QB>> void registerQuery(Writeable.Reader<QB> reader, QueryParser<QB> queryParser,
|
||||||
ParseField queryName) {
|
ParseField queryName) {
|
||||||
innerRegisterQueryParser(queryParser, queryName);
|
Tuple<ParseField, QueryParser<?>> parseFieldQueryParserTuple = new Tuple<>(queryName, queryParser);
|
||||||
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);
|
|
||||||
for (String name: queryName.getAllNamesIncludedDeprecated()) {
|
for (String name: queryName.getAllNamesIncludedDeprecated()) {
|
||||||
Tuple<ParseField, QueryParser<?>> previousValue = queryParsers.putIfAbsent(name, parseFieldQueryParserTuple);
|
Tuple<ParseField, QueryParser<?>> previousValue = queryParsers.putIfAbsent(name, parseFieldQueryParserTuple);
|
||||||
if (previousValue != null) {
|
if (previousValue != null) {
|
||||||
throw new IllegalArgumentException("Query parser [" + previousValue.v2() + "] already registered for name [" +
|
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() {
|
Set<String> getRegisteredQueries() {
|
||||||
|
|
Loading…
Reference in New Issue