Пример #1
0
        private BaseFilter _GeoDistanceRange(PropertyPathMarker field, Action <GeoDistanceRangeFilterDescriptor> filterDescriptor)
        {
            var filter = new GeoDistanceRangeFilterDescriptor();

            if (filterDescriptor != null)
            {
                filterDescriptor(filter);
            }

            return(this.SetDictionary("geo_distance_range", field, filter, (d, b) =>
            {
                var dd = new Dictionary <PropertyPathMarker, object>();
                dd.Add("from", filter._FromDistance);
                dd.Add("to", filter._ToDistance);
                if (!string.IsNullOrWhiteSpace(filter._GeoUnit))
                {
                    dd.Add("distance_type", filter._GeoUnit);
                }

                if (!string.IsNullOrWhiteSpace(filter._GeoOptimizeBBox))
                {
                    dd.Add("optimize_bbox", filter._GeoOptimizeBBox);
                }

                d.ForEachWithIndex((kv, i) => dd.Add(kv.Key, kv.Value));
                dd[field] = filter._Location;
                b.GeoDistanceRangeFilter = dd;
            }));
        }
        public MultiMatchQueryDescriptor <T> OnFieldsWithBoost(Action <FluentDictionary <string, double?> > boostableSelector)
        {
            var d = new FluentDictionary <string, double?>();

            boostableSelector(d);
            ((IMultiMatchQuery)this).Fields = d.Select(o => PropertyPathMarker.Create(o.Key, o.Value));
            return(this);
        }
Пример #3
0
        private BaseFilter _GeoPolygon(PropertyPathMarker fieldName, string[] points)
        {
            var filter = new GeoPolygonFilter {
                Points = points
            };

            return(this.SetDictionary("geo_polygon", fieldName, filter, (d, b) => { b.GeoPolygonFilter = d; }));
        }
Пример #4
0
        private FilterContainer _GeoPolygon(PropertyPathMarker fieldName, string[] points)
        {
            IGeoPolygonFilter filter = new GeoPolygonFilterDescriptor();

            filter.Points = points;
            filter.Field  = fieldName;
            return(this.New(filter, f => f.GeoPolygon = filter));
        }
        public MultiMatchQueryDescriptor <T> OnFieldsWithBoost(Action <FluentDictionary <Expression <Func <T, object> >, double?> > boostableSelector)
        {
            var d = new FluentDictionary <Expression <Func <T, object> >, double?>();

            boostableSelector(d);
            this._Fields = d.Select(o => PropertyPathMarker.Create(o.Key, o.Value));
            return(this);
        }
Пример #6
0
        /// <summary>
        /// A query that match on any (configurable) of the provided terms. This is a simpler syntax query for using a bool query with several term queries in the should clauses.
        /// </summary>
        public QueryContainer Terms <K>(Expression <Func <T, IEnumerable <K> > > objectPath, IEnumerable <K> terms)
        {
            PropertyPathMarker field = objectPath;

            return(this.TermsDescriptor <K>(t => t
                                            .OnField(field)
                                            .Terms(terms)
                                            ));
        }
Пример #7
0
		public string PropertyPath(PropertyPathMarker marker)
		{
			if (marker.IsConditionless())
				return null;
			var name = !marker.Name.IsNullOrEmpty() ? marker.Name : this.PropertyNameResolver.Resolve(marker.Type);
			if (marker.Boost.HasValue)
				name += "^" + marker.Boost.Value.ToString(CultureInfo.InvariantCulture);

			return name;
		}
Пример #8
0
        private BaseFilter _GeoIndexedShape(PropertyPathMarker field, Action <GeoIndexedShapeFilterDescriptor> filterDescriptor)
        {
            var filter = new GeoIndexedShapeFilterDescriptor();

            if (filterDescriptor != null)
            {
                filterDescriptor(filter);
            }

            return(this.SetDictionary("geo_shape", field, filter, (d, b) => { b.GeoShapeFilter = d; }));
        }
Пример #9
0
        private FilterContainer _GeoIndexedShape(PropertyPathMarker field, Action <GeoIndexedShapeFilterDescriptor> filterDescriptor)
        {
            var filter = new GeoIndexedShapeFilterDescriptor();

            if (filterDescriptor != null)
            {
                filterDescriptor(filter);
            }
            ((IGeoIndexedShapeFilter)filter).Field = field;
            return(this.New(filter, f => f.GeoShape = filter));
        }
 private TermsLookupFilterDescriptor _Lookup <T>(PropertyPathMarker field, string id, string index, string type)
 {
     ((ITermsLookupFilter)this).Path = field;
     ((ITermsLookupFilter)this).Id   = id;
     ((ITermsLookupFilter)this).Type = type ?? new TypeNameMarker {
         Type = typeof(T)
     };
     ((ITermsLookupFilter)this).Index = index ?? new IndexNameMarker {
         Type = typeof(T)
     };
     return(this);
 }
Пример #11
0
        private FilterContainer _GeoHashCell(PropertyPathMarker field, Action <GeoHashCellFilterDescriptor> filterDescriptor)
        {
            var filter = new GeoHashCellFilterDescriptor();

            if (filterDescriptor != null)
            {
                filterDescriptor(filter);
            }

            IGeoHashCellFilter ff = filter;

            ff.Field = field;
            return(New(filter, f => f.GeoHashCell = filter));
        }
Пример #12
0
        private FilterContainer _GeoDistanceRange(PropertyPathMarker field, Action <GeoDistanceRangeFilterDescriptor> filterDescriptor)
        {
            var filter = new GeoDistanceRangeFilterDescriptor();

            if (filterDescriptor != null)
            {
                filterDescriptor(filter);
            }

            IGeoDistanceRangeFilter ff = filter;

            ff.Field = field;
            return(this.New(ff, f => f.GeoDistanceRange = ff));
        }
Пример #13
0
 private GeoIndexedShapeFilterDescriptor _SetShape <T>(PropertyPathMarker field, string id, string index, string type)
 {
     ((IGeoIndexedShapeFilter)this).IndexedShape = new IndexedGeoShape
     {
         Field = field,
         Id    = id,
         Type  = type ?? new TypeNameMarker {
             Type = typeof(T)
         },
         Index = index ?? new IndexNameMarker {
             Type = typeof(T)
         }
     };
     return(this);
 }
Пример #14
0
 public PercentilesAggregationDescriptor <T> Field(Expression <Func <T, object> > field)
 {
     this._Field = field;
     return(this);
 }
Пример #15
0
 public DateHistogramAggregationDescriptor <T> Field(string field)
 {
     this._Field = field;
     return(this);
 }
Пример #16
0
 public TMetricAggregation Field(string field)
 {
     this._Field = field;
     return((TMetricAggregation)this);
 }
Пример #17
0
 public SignificantTermsAggregationDescriptor <T> Field(Expression <Func <T, object> > field)
 {
     this._Field = field;
     return(this);
 }
Пример #18
0
 public Ip4RangeAggregationDescriptor <T> Field(string field)
 {
     this._Field = field;
     return(this);
 }
Пример #19
0
 public TMetricAggregation Field(Expression <Func <T, object> > field)
 {
     this._Field = field;
     return((TMetricAggregation)this);
 }
Пример #20
0
 public SignificantTermsAggregationDescriptor <T> Field(string field)
 {
     this._Field = field;
     return(this);
 }
 internal static bool IsConditionless(this PropertyPathMarker marker)
 {
     return(marker == null || (marker.Name.IsNullOrEmpty() && marker.Type == null));
 }
Пример #22
0
 public GeoDistanceAggregationDescriptor <T> Field(Expression <Func <T, object> > field)
 {
     this._Field = field;
     return(this);
 }
Пример #23
0
 public DateHistogramAggregationDescriptor <T> Field(Expression <Func <T, object> > field)
 {
     this._Field = field;
     return(this);
 }
 public ExternalFieldDeclarationDescriptor <T> Path(string path)
 {
     this._Path = path;
     return(this);
 }
Пример #25
0
 public MatchQueryDescriptor <T> OnField(Expression <Func <T, object> > objectPath)
 {
     this._Field = objectPath;
     return(this);
 }
Пример #26
0
 public MatchQueryDescriptor <T> OnField(string field)
 {
     this._Field = field;
     return(this);
 }
Пример #27
0
 public GeoDistanceAggregationDescriptor <T> Field(string field)
 {
     this._Field = field;
     return(this);
 }
Пример #28
0
        private BaseFilter SetDictionary(
            string type,
            PropertyPathMarker key,
            object value,
            Action <Dictionary <PropertyPathMarker, object>, FilterDescriptor <T> > setter
            )
        {
            setter.ThrowIfNull("setter");
            var dictionary = new Dictionary <PropertyPathMarker, object>();

            if (key.IsConditionless())
            {
                return(CreateConditionlessFilterDescriptor(dictionary, type));
            }

            dictionary.Add(key, value);
            if (this._Cache.HasValue)
            {
                dictionary.Add("_cache", this._Cache);
            }
            if (!string.IsNullOrWhiteSpace(this._Name))
            {
                dictionary.Add("_name", this._Name);
            }
            if (!string.IsNullOrWhiteSpace(this._CacheKey))
            {
                dictionary.Add("_cache_key", this._CacheKey);
            }

            this.ResetCache();

            var bucket = new FilterDescriptor <T> {
                IsStrict = this.IsStrict, IsVerbatim = this.IsVerbatim
            };

            setter(dictionary, bucket);
            if (this.IsVerbatim)
            {
                return(bucket);
            }

            //find out if we are conditionless

            if (value == null)
            {
                return(CreateConditionlessFilterDescriptor(dictionary, type));
            }
            else if (value is string)
            {
                if (string.IsNullOrEmpty(value.ToString()))
                {
                    return(CreateConditionlessFilterDescriptor(value, type));
                }
            }
            else if (value is IEnumerable <BaseFilter> )
            {
                var l           = (IEnumerable <object>)value;
                var baseFilters = l.OfType <BaseFilter>().ToList();
                var allBaseFiltersConditionless = baseFilters.All(b => b.IsConditionless);
                if (!baseFilters.HasAny() || allBaseFiltersConditionless)
                {
                    return(CreateConditionlessFilterDescriptor(dictionary, type));
                }
            }
            else if (value is IEnumerable <string> )
            {
                var l       = (IEnumerable <string>)value;
                var strings = l.ToList();
                var allStringsNullOrEmpty = strings.All(s => s.IsNullOrEmpty());
                if (!strings.HasAny() || allStringsNullOrEmpty)
                {
                    return(CreateConditionlessFilterDescriptor(dictionary, type));
                }
            }
            else if (value is IEnumerable <object> )
            {
                var l = (IEnumerable <object>)value;
                if (!l.HasAny())
                {
                    return(CreateConditionlessFilterDescriptor(dictionary, type));
                }
            }
            else if (value is FilterBase)
            {
                var bf = (FilterBase)value;
                if (bf.IsConditionless)
                {
                    return(CreateConditionlessFilterDescriptor(bf, type));
                }
            }
            else if (value is FilterDescriptor <T> )
            {
                var bf = (FilterDescriptor <T>)value;
                if (bf.IsConditionless)
                {
                    return(CreateConditionlessFilterDescriptor(bf, type));
                }
            }
            else if (value is BaseQuery)
            {
                var bf = (BaseQuery)value;
                if (bf.IsConditionless)
                {
                    return(CreateConditionlessFilterDescriptor(bf, type));
                }
            }

            if (key.IsConditionless())
            {
                return(CreateConditionlessFilterDescriptor(value, type));
            }

            return(bucket);
        }
Пример #29
0
 public MissingAggregationDescriptor <T> Field(string field)
 {
     this._Field = field;
     return(this);
 }
 public ExternalFieldDeclarationDescriptor <T> Path(Expression <Func <T, object> > objectPath)
 {
     this._Path = objectPath;
     return(this);
 }