@Inject public IndicesQueriesRegistry( Settings settings, Set<QueryParser> injectedQueryParsers, NamedWriteableRegistry namedWriteableRegistry) { super(settings); Map<String, QueryParser<?>> queryParsers = new HashMap<>(); for (@SuppressWarnings("unchecked") QueryParser<? extends QueryBuilder> queryParser : injectedQueryParsers) { for (String name : queryParser.names()) { queryParsers.put(name, queryParser); } @SuppressWarnings("unchecked") NamedWriteable<? extends QueryBuilder> qb = queryParser.getBuilderPrototype(); namedWriteableRegistry.registerPrototype(QueryBuilder.class, qb); } // EmptyQueryBuilder is not registered as query parser but used internally. // We need to register it with the NamedWriteableRegistry in order to serialize it namedWriteableRegistry.registerPrototype(QueryBuilder.class, EmptyQueryBuilder.PROTOTYPE); this.queryParsers = unmodifiableMap(queryParsers); }
private void addQueryParser(Map<String, QueryParser> queryParsers, QueryParser queryParser) { for (String name : queryParser.names()) { queryParsers.put(name, queryParser); } }