Example usage for org.apache.lucene.document IntPoint newSetQuery

List of usage examples for org.apache.lucene.document IntPoint newSetQuery

Introduction

In this page you can find the example usage for org.apache.lucene.document IntPoint newSetQuery.

Prototype

public static Query newSetQuery(String field, Collection<Integer> values) 

Source Link

Document

Create a query matching any of the specified 1D values.

Usage

From source file:com.b2international.index.lucene.IntIndexField.java

License:Apache License

@Override
protected Query toSetQuery(Iterable<Integer> values) {
    return IntPoint.newSetQuery(fieldName(), ImmutableSet.copyOf(values));
}

From source file:org.apache.solr.schema.IntPointField.java

License:Apache License

@Override
public Query getSetQuery(QParser parser, SchemaField field, Collection<String> externalVal) {
    assert externalVal.size() > 0;
    int[] values = new int[externalVal.size()];
    int i = 0;//from  ww  w .  j  a  v  a  2 s  .c o m
    for (String val : externalVal) {
        values[i] = Integer.parseInt(val);
        i++;
    }
    return IntPoint.newSetQuery(field.getName(), values);
}

From source file:org.apache.solr.search.join.GraphPointsCollector.java

License:Apache License

@Override
public Query getResultQuery(SchemaField matchField, boolean useAutomaton) {
    if (set.cardinality() == 0)
        return null;

    Query q = null;/* w w w.  j  a v  a 2s. c om*/

    // How we interpret the longs collected depends on the field we collect from (single valued can be diff from multi valued)
    // The basic type of the from & to field must match though (int/long/float/double)
    NumberType ntype = collectField.getType().getNumberType();
    boolean multiValued = collectField.multiValued();

    if (ntype == NumberType.LONG || ntype == NumberType.DATE) {
        long[] vals = new long[set.cardinality()];
        int i = 0;
        for (LongIterator iter = set.iterator(); iter.hasNext();) {
            long bits = iter.next();
            long v = bits;
            vals[i++] = v;
        }
        q = LongPoint.newSetQuery(matchField.getName(), vals);
    } else if (ntype == NumberType.INTEGER) {
        int[] vals = new int[set.cardinality()];
        int i = 0;
        for (LongIterator iter = set.iterator(); iter.hasNext();) {
            long bits = iter.next();
            int v = (int) bits;
            vals[i++] = v;
        }
        q = IntPoint.newSetQuery(matchField.getName(), vals);
    } else if (ntype == NumberType.DOUBLE) {
        double[] vals = new double[set.cardinality()];
        int i = 0;
        for (LongIterator iter = set.iterator(); iter.hasNext();) {
            long bits = iter.next();
            double v = multiValued ? NumericUtils.sortableLongToDouble(bits) : Double.longBitsToDouble(bits);
            vals[i++] = v;
        }
        q = DoublePoint.newSetQuery(matchField.getName(), vals);
    } else if (ntype == NumberType.FLOAT) {
        float[] vals = new float[set.cardinality()];
        int i = 0;
        for (LongIterator iter = set.iterator(); iter.hasNext();) {
            long bits = iter.next();
            float v = multiValued ? NumericUtils.sortableIntToFloat((int) bits)
                    : Float.intBitsToFloat((int) bits);
            vals[i++] = v;
        }
        q = FloatPoint.newSetQuery(matchField.getName(), vals);
    }

    return q;
}