Search in sources :

Example 71 with ConstantScoreQuery

use of org.apache.lucene.search.ConstantScoreQuery in project crate by crate.

the class RegexpMatchOperator method toQuery.

@Override
public Query toQuery(Reference ref, Literal<?> literal, Context context) {
    String pattern = (String) literal.value();
    Term term = new Term(ref.column().fqn(), pattern);
    if (RegexpFlags.isPcrePattern(pattern)) {
        return new CrateRegexQuery(term);
    } else {
        return new ConstantScoreQuery(new RegexpQuery(term, RegExp.ALL));
    }
}
Also used : CrateRegexQuery(io.crate.lucene.match.CrateRegexQuery) ConstantScoreQuery(org.apache.lucene.search.ConstantScoreQuery) Term(org.apache.lucene.index.Term) RegexpQuery(org.apache.lucene.search.RegexpQuery)

Aggregations

ConstantScoreQuery (org.apache.lucene.search.ConstantScoreQuery)71 BooleanQuery (org.apache.lucene.search.BooleanQuery)46 TermQuery (org.apache.lucene.search.TermQuery)45 Query (org.apache.lucene.search.Query)43 Term (org.apache.lucene.index.Term)33 MatchAllDocsQuery (org.apache.lucene.search.MatchAllDocsQuery)19 IndexSearcher (org.apache.lucene.search.IndexSearcher)17 BoostQuery (org.apache.lucene.search.BoostQuery)14 ArrayList (java.util.ArrayList)13 MatchNoDocsQuery (org.apache.lucene.search.MatchNoDocsQuery)13 TermRangeQuery (org.apache.lucene.search.TermRangeQuery)12 TopDocs (org.apache.lucene.search.TopDocs)12 MultiTermQuery (org.apache.lucene.search.MultiTermQuery)11 Test (org.junit.Test)11 Document (org.apache.lucene.document.Document)10 Sort (org.apache.lucene.search.Sort)9 StringField (org.apache.lucene.document.StringField)8 IndexReader (org.apache.lucene.index.IndexReader)8 BooleanClause (org.apache.lucene.search.BooleanClause)8 RegexpQuery (org.apache.lucene.search.RegexpQuery)8