Beispiel #1
0
        private Query CreateRangeQuery(IFieldMappingInfo mapping, QueryType queryType, LuceneQueryPredicateExpression lowerBoundExpression, LuceneQueryPredicateExpression upperBoundExpression)
        {
            var lowerRange = RangeType.Inclusive;
            var upperRange = (queryType == QueryType.LessThan || queryType == QueryType.GreaterThan) ? RangeType.Exclusive : RangeType.Inclusive;

            if (upperBoundExpression == null)
            {
                lowerRange = upperRange;
                upperRange = RangeType.Inclusive;
            }

            if (mapping.IsNumericField)
            {
                var lowerBound = lowerBoundExpression == null ? null : EvaluateExpression(lowerBoundExpression);
                var upperBound = upperBoundExpression == null ? null : EvaluateExpression(upperBoundExpression);
                return(NumericRangeUtils.CreateNumericRangeQuery(mapping.FieldName, (ValueType)lowerBound, (ValueType)upperBound, lowerRange, upperRange));
            }
            else
            {
                var minInclusive = lowerRange == RangeType.Inclusive;
                var maxInclusive = upperRange == RangeType.Inclusive;

                var lowerBound = lowerBoundExpression == null ? null : EvaluateExpressionToStringAndAnalyze(lowerBoundExpression, mapping);
                var upperBound = upperBoundExpression == null ? null : EvaluateExpressionToStringAndAnalyze(upperBoundExpression, mapping);
                return(new TermRangeQuery(mapping.FieldName, lowerBound, upperBound, minInclusive, maxInclusive));
            }
        }
Beispiel #2
0
 public override Query CreateRangeQuery(object lowerBound, object upperBound, RangeType lowerRange, RangeType upperRange)
 {
     if (lowerBound != null && !propertyInfo.PropertyType.IsInstanceOfType(lowerBound))
     {
         lowerBound = ConvertToSupportedValueType(lowerBound);
     }
     if (upperBound != null && !propertyInfo.PropertyType.IsInstanceOfType(upperBound))
     {
         upperBound = ConvertToSupportedValueType(upperBound);
     }
     return(NumericRangeUtils.CreateNumericRangeQuery(fieldName, (ValueType)lowerBound, (ValueType)upperBound, lowerRange, upperRange));
 }
Beispiel #3
0
 public override Query CreateRangeQuery(object lowerBound, object upperBound, RangeType lowerRange, RangeType upperRange)
 {
     return(NumericRangeUtils.CreateNumericRangeQuery(fieldName, (ValueType)lowerBound, (ValueType)upperBound, lowerRange, upperRange));
 }