Search in sources :

Example 16 with TermInSetQuery

use of org.apache.lucene.search.TermInSetQuery in project lucene-solr by apache.

the class FieldType method getSetQuery.

/** @lucene.experimental  */
public Query getSetQuery(QParser parser, SchemaField field, Collection<String> externalVals) {
    if (!field.indexed()) {
        BooleanQuery.Builder builder = new BooleanQuery.Builder();
        for (String externalVal : externalVals) {
            Query subq = getFieldQuery(parser, field, externalVal);
            builder.add(subq, BooleanClause.Occur.SHOULD);
        }
        return builder.build();
    }
    List<BytesRef> lst = new ArrayList<>(externalVals.size());
    BytesRefBuilder br = new BytesRefBuilder();
    for (String externalVal : externalVals) {
        readableToIndexed(externalVal, br);
        lst.add(br.toBytesRef());
    }
    return new TermInSetQuery(field.getName(), lst);
}
Also used : BooleanQuery(org.apache.lucene.search.BooleanQuery) BytesRefBuilder(org.apache.lucene.util.BytesRefBuilder) Query(org.apache.lucene.search.Query) MultiTermQuery(org.apache.lucene.search.MultiTermQuery) TermInSetQuery(org.apache.lucene.search.TermInSetQuery) PrefixQuery(org.apache.lucene.search.PrefixQuery) SolrRangeQuery(org.apache.solr.query.SolrRangeQuery) TermQuery(org.apache.lucene.search.TermQuery) BooleanQuery(org.apache.lucene.search.BooleanQuery) TermInSetQuery(org.apache.lucene.search.TermInSetQuery) BytesRefBuilder(org.apache.lucene.util.BytesRefBuilder) CharsRefBuilder(org.apache.lucene.util.CharsRefBuilder) ArrayList(java.util.ArrayList) BytesRef(org.apache.lucene.util.BytesRef)

Aggregations

TermInSetQuery (org.apache.lucene.search.TermInSetQuery)16 BytesRef (org.apache.lucene.util.BytesRef)12 ArrayList (java.util.ArrayList)9 BooleanQuery (org.apache.lucene.search.BooleanQuery)4 Query (org.apache.lucene.search.Query)4 TermQuery (org.apache.lucene.search.TermQuery)4 Term (org.apache.lucene.index.Term)3 ConstantScoreQuery (org.apache.lucene.search.ConstantScoreQuery)3 BytesRefBuilder (org.apache.lucene.util.BytesRefBuilder)3 HashSet (java.util.HashSet)2 IndexReader (org.apache.lucene.index.IndexReader)2 MatchNoDocsQuery (org.apache.lucene.search.MatchNoDocsQuery)2 Cell (org.apache.lucene.spatial.prefix.tree.Cell)2 CellIterator (org.apache.lucene.spatial.prefix.tree.CellIterator)2 Directory (org.apache.lucene.store.Directory)2 QueryWrapperFilter (org.apache.solr.search.QueryWrapperFilter)2 Shape (org.locationtech.spatial4j.shape.Shape)2 IntObjectCursor (com.carrotsearch.hppc.cursors.IntObjectCursor)1 LongCursor (com.carrotsearch.hppc.cursors.LongCursor)1 Repeat (com.carrotsearch.randomizedtesting.annotations.Repeat)1