Search in sources :

Example 1 with CrateRegexQuery

use of io.crate.lucene.match.CrateRegexQuery 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

CrateRegexQuery (io.crate.lucene.match.CrateRegexQuery)1 Term (org.apache.lucene.index.Term)1 ConstantScoreQuery (org.apache.lucene.search.ConstantScoreQuery)1 RegexpQuery (org.apache.lucene.search.RegexpQuery)1