List of usage examples for org.apache.lucene.document DoublePoint newSetQuery
public static Query newSetQuery(String field, Collection<Double> values)
From source file:org.apache.solr.schema.DoublePointField.java
License:Apache License
@Override public Query getSetQuery(QParser parser, SchemaField field, Collection<String> externalVal) { assert externalVal.size() > 0; double[] values = new double[externalVal.size()]; int i = 0;/* ww w. j ava 2 s . co m*/ for (String val : externalVal) { values[i] = Double.parseDouble(val); i++; } return DoublePoint.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 w ww . j a v a2s.c o 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; }