Java Code Examples for org.apache.lucene.document.DoublePoint#nextDown()

The following examples show how to use org.apache.lucene.document.DoublePoint#nextDown() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NumericFieldType.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
protected Query getRangeQueryForMultiValuedDoubleDocValues(SchemaField sf, String min, String max, boolean minInclusive, boolean maxInclusive) {
  double minVal,maxVal;
  if (min == null) {
    minVal = Double.NEGATIVE_INFINITY;
  } else {
    minVal = parseDoubleFromUser(sf.getName(), min);
    if (!minInclusive) {
      if (minVal == Double.POSITIVE_INFINITY) return new MatchNoDocsQuery();
      minVal = DoublePoint.nextUp(minVal);
    }
  }
  if (max == null) {
    maxVal = Double.POSITIVE_INFINITY;
  } else {
    maxVal = parseDoubleFromUser(sf.getName(), max);
    if (!maxInclusive) {
      if (maxVal == Double.NEGATIVE_INFINITY) return new MatchNoDocsQuery();
      maxVal = DoublePoint.nextDown(maxVal);
    }
  }
  Long minBits = NumericUtils.doubleToSortableLong(minVal);
  Long maxBits = NumericUtils.doubleToSortableLong(maxVal);
  return numericDocValuesRangeQuery(sf.getName(), minBits, maxBits, true, true, true);
}
 
Example 2
Source File: DoublePointField.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
@Override
public Query getPointRangeQuery(QParser parser, SchemaField field, String min, String max, boolean minInclusive,
    boolean maxInclusive) {
  double actualMin, actualMax;
  if (min == null) {
    actualMin = Double.NEGATIVE_INFINITY;
  } else {
    actualMin = parseDoubleFromUser(field.getName(), min);
    if (!minInclusive) {
      if (actualMin == Double.POSITIVE_INFINITY) return new MatchNoDocsQuery();
      actualMin = DoublePoint.nextUp(actualMin);
    }
  }
  if (max == null) {
    actualMax = Double.POSITIVE_INFINITY;
  } else {
    actualMax = parseDoubleFromUser(field.getName(), max);
    if (!maxInclusive) {
      if (actualMax == Double.NEGATIVE_INFINITY) return new MatchNoDocsQuery();
      actualMax = DoublePoint.nextDown(actualMax);
    }
  }
  return DoublePoint.newRangeQuery(field.getName(), actualMin, actualMax);
}
 
Example 3
Source File: DoubleQuery.java    From HongsCORE with MIT License 6 votes vote down vote up
@Override
public Query whr(String k, Object n, Object x, boolean l, boolean g) {
    if (n == null && x == null) {
        throw new NullPointerException("Range for "+k+" must be number, but null");
    }
    double n2, x2;
    if (n == null || "".equals(n)) {
        n2 = Double.NEGATIVE_INFINITY;
    } else {
        n2 = Synt.asFloat (n);
        if (!l) {
            n2 = DoublePoint.nextUp  (n2);
        }
    }
    if (x == null || "".equals(x)) {
        x2 = Double.POSITIVE_INFINITY;
    } else {
        x2 = Synt.asFloat (x);
        if (!g) {
            x2 = DoublePoint.nextDown(x2);
        }
    }
    Query   q2 = DoublePoint.newRangeQuery("@"+k, n2, x2);
    return  q2;
}
 
Example 4
Source File: NumberFieldMapper.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public Query rangeQuery(String field, Object lowerTerm, Object upperTerm,
                 boolean includeLower, boolean includeUpper,
                 boolean hasDocValues) {
    double l = Double.NEGATIVE_INFINITY;
    double u = Double.POSITIVE_INFINITY;
    if (lowerTerm != null) {
        l = parse(lowerTerm, false);
        if (includeLower == false) {
            l = DoublePoint.nextUp(l);
        }
    }
    if (upperTerm != null) {
        u = parse(upperTerm, false);
        if (includeUpper == false) {
            u = DoublePoint.nextDown(u);
        }
    }
    Query query = DoublePoint.newRangeQuery(field, l, u);
    if (hasDocValues) {
        Query dvQuery = SortedNumericDocValuesField.newSlowRangeQuery(field,
                NumericUtils.doubleToSortableLong(l),
                NumericUtils.doubleToSortableLong(u));
        query = new IndexOrDocValuesQuery(query, dvQuery);
    }
    return query;
}