org.elasticsearch.index.query.QueryRewriteContext Java Examples
The following examples show how to use
org.elasticsearch.index.query.QueryRewriteContext.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExplorerQueryBuilder.java From elasticsearch-learning-to-rank with Apache License 2.0 | 6 votes |
@Override protected QueryBuilder doRewrite(QueryRewriteContext queryRewriteContext) throws IOException { if (queryRewriteContext != null) { ExplorerQueryBuilder rewritten = new ExplorerQueryBuilder(); rewritten.type = this.type; rewritten.query = Rewriteable.rewrite(query, queryRewriteContext); rewritten.boost(boost()); rewritten.queryName(queryName()); if (!rewritten.equals(this)) { return rewritten; } } return super.doRewrite(queryRewriteContext); }
Example #2
Source File: LtrQueryBuilder.java From elasticsearch-learning-to-rank with Apache License 2.0 | 5 votes |
@Override public QueryBuilder doRewrite(QueryRewriteContext ctx) throws IOException { if (_features == null || _rankLibScript == null || _features.isEmpty()) { return new MatchAllQueryBuilder(); } List<QueryBuilder> newFeatures = null; boolean changed = false; int i = 0; for (QueryBuilder qb : _features) { QueryBuilder newQuery = Rewriteable.rewrite(qb, ctx); changed |= newQuery != qb; if (changed) { if (newFeatures == null) { newFeatures = new ArrayList<>(_features.size()); newFeatures.addAll(_features.subList(0, i)); } newFeatures.add(newQuery); } i++; } if (changed) { assert newFeatures.size() == _features.size(); return new LtrQueryBuilder(_rankLibScript, newFeatures); } return this; }
Example #3
Source File: ExactPhraseQueryBuilder.java From elasticsearch-plugin-bundle with GNU Affero General Public License v3.0 | 5 votes |
@Override protected QueryBuilder doRewrite(QueryRewriteContext queryRewriteContext) throws IOException { QueryBuilder rewrittenQuery = query.rewrite(queryRewriteContext); if (rewrittenQuery != query) { return new ExactPhraseQueryBuilder(rewrittenQuery); } return this; }