Example #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;
            }));
        }
Example #2
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));
        }
Example #3
0
        public void GeoDistanceRange(string field, Action <GeoDistanceRangeFilterDescriptor> filterDescriptor)
        {
            var filter = new GeoDistanceRangeFilterDescriptor();

            filterDescriptor(filter);
            if (filter._FromDistance == null)
            {
                throw new ArgumentNullException("FromDistance",
                                                "Distance should be set when using the geo distance range DSL");
            }

            if (filter._ToDistance == null)
            {
                throw new ArgumentNullException("ToDistance",
                                                "Distance should be set when using the geo distance range DSL");
            }

            this.SetDictionary(field, filter._Location, d =>
            {
                var dd = new Dictionary <string, 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));

                this.GeoDistanceRangeFilter = dd;
            });
        }