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

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

            return(this.SetDictionary("geo_distance", field, filter, (d, b) =>
            {
                var dd = new Dictionary <PropertyPathMarker, object>();
                dd.Add("distance", filter._Distance);

                if (!string.IsNullOrWhiteSpace(filter._GeoUnit))
                {
                    dd.Add("unit", 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.GeoDistanceFilter = dd;
            }));
        }
Пример #2
0
        private FilterContainer _GeoDistance(PropertyPathMarker field, Action <GeoDistanceFilterDescriptor> filterDescriptor)
        {
            var filter = new GeoDistanceFilterDescriptor();

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

            IGeoDistanceFilter ff = filter;

            ff.Field = field;
            return(this.New(filter, f => f.GeoDistance = filter));
        }
Пример #3
0
        public void GeoDistance(string field, Action <GeoDistanceFilterDescriptor> filterDescriptor)
        {
            var filter = new GeoDistanceFilterDescriptor();

            filterDescriptor(filter);
            this.SetDictionary(field, filter._Location, d => {
                var dd = new Dictionary <string, object>();
                dd.Add("distance", filter._Distance);

                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.GeoDistanceFilter = dd;
            });
        }