Java Code Examples for org.apache.lucene.search.ConstantScoreQuery#getQuery()

The following examples show how to use org.apache.lucene.search.ConstantScoreQuery#getQuery() . 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: ConstantScoreQueryExtractor.java    From solr-redis with Apache License 2.0 5 votes vote down vote up
@Override
public void extract(final ConstantScoreQuery q, final Iterable<QueryExtractor<? extends Query>> extractors,
        final List<Query> extractedQueries) throws UnsupportedOperationException {
  if (q.getQuery() != null) {
    extractQuery(q.getQuery(), extractors, extractedQueries);
  } else {
    extractedQueries.add(q);
  }
}
 
Example 2
Source File: ConstantScoreQueryExtractor.java    From solr-redis with Apache License 2.0 5 votes vote down vote up
@Override
public void extractSubQueriesFields(final ConstantScoreQuery q,
        final Iterable<QueryExtractor<? extends Query>> extractors,
        final Set<String> extractedFields) throws UnsupportedOperationException {
  if (q.getQuery() != null) {
    extractFields(q.getQuery(), extractors, extractedFields);
  }
}
 
Example 3
Source File: TestRedisQParser.java    From solr-redis with Apache License 2.0 5 votes vote down vote up
private static Set<Term> extractTerms(IndexSearcher searcher, Query query) throws IOException {
  final Set<Term> terms = new HashSet<>();
  Query rewrittenQuery = searcher.rewrite(query);
  if (rewrittenQuery instanceof ConstantScoreQuery) {
    ConstantScoreQuery constantScoreQuery = (ConstantScoreQuery)rewrittenQuery;
    rewrittenQuery = constantScoreQuery.getQuery();
  }
  searcher.createNormalizedWeight(rewrittenQuery, true).extractTerms(terms);
  return terms;
}
 
Example 4
Source File: QueryTransformer.java    From elasticsearch-plugin-bundle with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public Query handle(Query query, QueryTransformer queryTransformer) {
    ConstantScoreQuery constantScoreQuery = (ConstantScoreQuery) query;
    Query newInnerConstantScoreQuery = queryTransformer.transform(constantScoreQuery.getQuery());
    if (newInnerConstantScoreQuery != constantScoreQuery.getQuery()) {
        return new ConstantScoreQuery(newInnerConstantScoreQuery);
    }
    return query;
}