@Override
 public Filter rangeFilter(
     IndexFieldDataService fieldData,
     Object lowerTerm,
     Object upperTerm,
     boolean includeLower,
     boolean includeUpper,
     @Nullable QueryParseContext context) {
   return NumericRangeFieldDataFilter.newIntRange(
       (IndexNumericFieldData) fieldData.getForField(this),
       lowerTerm == null ? null : parseValue(lowerTerm),
       upperTerm == null ? null : parseValue(upperTerm),
       includeLower,
       includeUpper);
 }
 @Override
 public Filter rangeFilter(
     FieldDataCache fieldDataCache,
     String lowerTerm,
     String upperTerm,
     boolean includeLower,
     boolean includeUpper,
     @Nullable QueryParseContext context) {
   return NumericRangeFieldDataFilter.newShortRange(
       fieldDataCache,
       names.indexName(),
       lowerTerm == null ? null : Short.parseShort(lowerTerm),
       upperTerm == null ? null : Short.parseShort(upperTerm),
       includeLower,
       includeUpper);
 }
Exemplo n.º 3
0
 @Override
 public Filter rangeFilter(
     FieldDataCache fieldDataCache,
     Object lowerTerm,
     Object upperTerm,
     boolean includeLower,
     boolean includeUpper,
     @Nullable QueryParseContext context) {
   return NumericRangeFieldDataFilter.newLongRange(
       fieldDataCache,
       names.indexName(),
       lowerTerm == null ? null : parseValue(lowerTerm),
       upperTerm == null ? null : parseValue(upperTerm),
       includeLower,
       includeUpper);
 }
Exemplo n.º 4
0
  private Filter innerRangeFilter(
      IndexNumericFieldData fieldData,
      Object lowerTerm,
      Object upperTerm,
      boolean includeLower,
      boolean includeUpper,
      @Nullable DateTimeZone timeZone,
      @Nullable DateMathParser forcedDateParser,
      @Nullable Boolean explicitCaching) {
    boolean cache;
    boolean cacheable = true;
    Long lowerVal = null;
    Long upperVal = null;
    if (lowerTerm != null) {
      if (lowerTerm instanceof Number) {
        lowerVal = ((Number) lowerTerm).longValue();
      } else {
        String value = convertToString(lowerTerm);
        cacheable = !hasDateExpressionWithNoRounding(value);
        lowerVal = parseToMilliseconds(value, false, timeZone, forcedDateParser);
      }
    }
    if (upperTerm != null) {
      if (upperTerm instanceof Number) {
        upperVal = ((Number) upperTerm).longValue();
      } else {
        String value = convertToString(upperTerm);
        cacheable = cacheable && !hasDateExpressionWithNoRounding(value);
        upperVal = parseToMilliseconds(value, includeUpper, timeZone, forcedDateParser);
      }
    }

    if (explicitCaching != null) {
      if (explicitCaching) {
        cache = cacheable;
      } else {
        cache = false;
      }
    } else {
      cache = cacheable;
    }

    Filter filter;
    if (fieldData != null) {
      filter =
          NumericRangeFieldDataFilter.newLongRange(
              fieldData, lowerVal, upperVal, includeLower, includeUpper);
    } else {
      filter =
          NumericRangeFilter.newLongRange(
              names.indexName(), precisionStep, lowerVal, upperVal, includeLower, includeUpper);
    }

    if (!cache) {
      // We don't cache range filter if `now` date expression is used and also when a compound
      // filter wraps
      // a range filter with a `now` date expressions.
      return NoCacheFilter.wrap(filter);
    } else {
      return filter;
    }
  }