public override Query Process(RangeQueryOptions opt, AzureQueryMapper mapper) { object obj = opt.FieldFromValue ?? opt.FieldToValue; if (obj == null || !obj.GetType().IsPrimitive) { return((Query)null); } switch (Type.GetTypeCode(obj.GetType())) { case TypeCode.SByte: case TypeCode.Byte: case TypeCode.Int16: case TypeCode.UInt16: case TypeCode.Int32: case TypeCode.UInt32: case TypeCode.Int64: case TypeCode.UInt64: case TypeCode.Decimal: return(this.BuildLongRangeQuery(opt)); case TypeCode.Single: case TypeCode.Double: return(this.BuildDoubleRangeQuery(opt)); default: return((Query)null); } }
protected Query BuildLongRangeQuery(RangeQueryOptions opt) { long? min = opt.FieldFromValue != null ? new long?(Convert.ToInt64(opt.FieldFromValue)) : new long?(); long? max = opt.FieldToValue != null ? new long?(Convert.ToInt64(opt.FieldToValue)) : new long?(); Query query = (Query)NumericRangeQuery.NewLongRange(opt.FieldName, min, max, opt.IncludeLower, opt.IncludeUpper); query.Boost = opt.Boost; return query; }
protected Query BuildDoubleRangeQuery(RangeQueryOptions opt) { double? min = opt.FieldFromValue != null ? new double?(Convert.ToDouble(opt.FieldFromValue)) : new double?(); double? max = opt.FieldToValue != null ? new double?(Convert.ToDouble(opt.FieldToValue)) : new double?(); Query query = (Query)NumericRangeQuery.NewDoubleRange(opt.FieldName, min, max, opt.IncludeLower, opt.IncludeUpper); query.Boost = opt.Boost; return query; }
public override Query Process(RangeQueryOptions options, AzureQueryMapper mapper) { if (!(options.FieldFromValue is DateTime) && !(options.FieldToValue is DateTime)) return (Query)null; options.FieldFromValue = this.ConvertToUtc(options.FieldFromValue, options.FieldName, mapper); options.FieldToValue = this.ConvertToUtc(options.FieldToValue, options.FieldName, mapper); return new DefaultRangeQueryProcessor().Process(options, mapper); }
protected Query BuildDoubleRangeQuery(RangeQueryOptions opt) { double?min = opt.FieldFromValue != null ? new double?(Convert.ToDouble(opt.FieldFromValue)) : new double?(); double?max = opt.FieldToValue != null ? new double?(Convert.ToDouble(opt.FieldToValue)) : new double?(); Query query = (Query)NumericRangeQuery.NewDoubleRange(opt.FieldName, min, max, opt.IncludeLower, opt.IncludeUpper); query.Boost = opt.Boost; return(query); }
protected Query BuildLongRangeQuery(RangeQueryOptions opt) { long? min = opt.FieldFromValue != null ? new long?(Convert.ToInt64(opt.FieldFromValue)) : new long?(); long? max = opt.FieldToValue != null ? new long?(Convert.ToInt64(opt.FieldToValue)) : new long?(); Query query = (Query)NumericRangeQuery.NewLongRange(opt.FieldName, min, max, opt.IncludeLower, opt.IncludeUpper); query.Boost = opt.Boost; return(query); }
public override Query Process(RangeQueryOptions options, AzureQueryMapper mapper) { if (!(options.FieldFromValue is DateTime) && !(options.FieldToValue is DateTime)) { return((Query)null); } options.FieldFromValue = this.ConvertToUtc(options.FieldFromValue, options.FieldName, mapper); options.FieldToValue = this.ConvertToUtc(options.FieldToValue, options.FieldName, mapper); return(new DefaultRangeQueryProcessor().Process(options, mapper)); }
public override Query Process(RangeQueryOptions options, AzureQueryMapper mapper) { string lowerTerm = (string)null; string upperTerm = (string)null; if (options.FieldFromValue != null) lowerTerm = this.NormalizeValue(mapper.ValueFormatter.FormatValueForIndexStorage(options.FieldFromValue, options.FieldName).ToString(), mapper); if (options.FieldToValue != null) upperTerm = this.NormalizeValue(mapper.ValueFormatter.FormatValueForIndexStorage(options.FieldToValue, options.FieldName).ToString(), mapper); TermRangeQuery termRangeQuery = new TermRangeQuery(options.FieldName, lowerTerm, upperTerm, options.IncludeLower, options.IncludeUpper); termRangeQuery.Boost = options.Boost; return (Query)termRangeQuery; }
public Query BuildRangeQuery(RangeQueryOptions options, AzureQueryMapper mapper, bool useDefaultProcessor) { if (string.IsNullOrEmpty(options.FieldName)) throw new ArgumentException("RangeQueryOptions.FieldName cannot be null or empty string."); foreach (RangeQueryProcessor rangeQueryProcessor in this.GetProcessors()) { Query query = rangeQueryProcessor.Process(options, mapper); if (query != null) return query; } if (useDefaultProcessor) return new DefaultRangeQueryProcessor().Process(options, mapper); return (Query)null; }
public override Query Process(RangeQueryOptions options, AzureQueryMapper mapper) { string lowerTerm = (string)null; string upperTerm = (string)null; if (options.FieldFromValue != null) { lowerTerm = this.NormalizeValue(mapper.ValueFormatter.FormatValueForIndexStorage(options.FieldFromValue, options.FieldName).ToString(), mapper); } if (options.FieldToValue != null) { upperTerm = this.NormalizeValue(mapper.ValueFormatter.FormatValueForIndexStorage(options.FieldToValue, options.FieldName).ToString(), mapper); } TermRangeQuery termRangeQuery = new TermRangeQuery(options.FieldName, lowerTerm, upperTerm, options.IncludeLower, options.IncludeUpper); termRangeQuery.Boost = options.Boost; return((Query)termRangeQuery); }
public Query BuildRangeQuery(RangeQueryOptions options, AzureQueryMapper mapper, bool useDefaultProcessor) { if (string.IsNullOrEmpty(options.FieldName)) { throw new ArgumentException("RangeQueryOptions.FieldName cannot be null or empty string."); } foreach (RangeQueryProcessor rangeQueryProcessor in this.GetProcessors()) { Query query = rangeQueryProcessor.Process(options, mapper); if (query != null) { return(query); } } if (useDefaultProcessor) { return(new DefaultRangeQueryProcessor().Process(options, mapper)); } return((Query)null); }
public override Query Process(RangeQueryOptions opt, AzureQueryMapper mapper) { object obj = opt.FieldFromValue ?? opt.FieldToValue; if (obj == null || !obj.GetType().IsPrimitive) return (Query)null; switch (Type.GetTypeCode(obj.GetType())) { case TypeCode.SByte: case TypeCode.Byte: case TypeCode.Int16: case TypeCode.UInt16: case TypeCode.Int32: case TypeCode.UInt32: case TypeCode.Int64: case TypeCode.UInt64: case TypeCode.Decimal: return this.BuildLongRangeQuery(opt); case TypeCode.Single: case TypeCode.Double: return this.BuildDoubleRangeQuery(opt); default: return (Query)null; } }
public abstract Query Process(RangeQueryOptions options, AzureQueryMapper mapper);
public abstract Query Process(RangeQueryOptions options, AzureQueryMapper mapper);