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

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

Introduction

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

Prototype

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

Source Link

Document

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

Usage

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

License:Apache License

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

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

License:Apache License

@Override
public Query getSetQuery(QParser parser, SchemaField field, Collection<String> externalVals) {
    assert externalVals.size() > 0;
    if (!field.indexed()) {
        return super.getSetQuery(parser, field, externalVals);
    }/*from  w w w .j  a v a2  s  .  co  m*/
    long[] values = new long[externalVals.size()];
    int i = 0;
    for (String val : externalVals) {
        values[i] = DateMathParser.parseMath(null, val).getTime();
        i++;
    }
    return LongPoint.newSetQuery(field.getName(), values);
}

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

License:Apache License

@Override
public Query getSetQuery(QParser parser, SchemaField field, Collection<String> externalVal) {
    assert externalVal.size() > 0;
    long[] values = new long[externalVal.size()];
    int i = 0;//from  w w w. j  a  va 2s  .c  om
    for (String val : externalVal) {
        values[i] = Long.parseLong(val);
        i++;
    }
    return LongPoint.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;/*from ww w.  j a va  2 s.co  m*/

    // 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;
}