@@ -71,6 +71,10 @@ public FilterDescriptor<T> Cache(bool cache)
7171 [ JsonConverter ( typeof ( DictionaryKeysAreNotPropertyNamesJsonConverter ) ) ]
7272 internal Dictionary < string , object > GeoPolygonFilter { get ; set ; }
7373
74+ [ JsonProperty ( PropertyName = "geo_shape" ) ]
75+ [ JsonConverter ( typeof ( DictionaryKeysAreNotPropertyNamesJsonConverter ) ) ]
76+ internal Dictionary < string , object > GeoShapeFilter { get ; set ; }
77+
7478 [ JsonProperty ( PropertyName = "limit" ) ]
7579 internal LimitFilter LimitFilter { get ; set ; }
7680
@@ -409,6 +413,7 @@ public BaseFilter GeoDistance(string field, Action<GeoDistanceFilterDescriptor>
409413 } ) ;
410414
411415 }
416+
412417 /// <summary>
413418 /// Filters documents that exists within a range from a specific point:
414419 /// </summary>
@@ -424,17 +429,11 @@ public BaseFilter GeoDistanceRange(string field, Action<GeoDistanceRangeFilterDe
424429 {
425430 var filter = new GeoDistanceRangeFilterDescriptor ( ) ;
426431 if ( filterDescriptor == null )
427- return CreateConditionlessFilterDescriptor ( "geo_distance " , filter ) ;
432+ return CreateConditionlessFilterDescriptor ( "geo_distance_range " , filter ) ;
428433
429434 filterDescriptor ( filter ) ;
430- if ( this . IsStrict && filter . _FromDistance == null )
431- throw new DslException ( "Missing from distance, Distance should be set when using the geo distance range DSL in strict mode" ) ;
432-
433- if ( this . IsStrict && filter . _ToDistance == null )
434- throw new DslException ( "Missing to distance, Distance should be set when using the geo distance range DSL in strict mode" ) ;
435-
436435 if ( filter . IsConditionless )
437- return CreateConditionlessFilterDescriptor ( "geo_distance " , filter ) ;
436+ return CreateConditionlessFilterDescriptor ( "geo_distance_range " , filter ) ;
438437
439438 return this . SetDictionary ( "geo_distance_range" , field , filter . _Location , ( d , b ) =>
440439 {
@@ -451,8 +450,36 @@ public BaseFilter GeoDistanceRange(string field, Action<GeoDistanceRangeFilterDe
451450 d . ForEachWithIndex ( ( kv , i ) => dd . Add ( kv . Key , kv . Value ) ) ;
452451 b . GeoDistanceRangeFilter = dd ;
453452 } ) ;
453+ }
454+
455+ /// <summary>
456+ /// Filters documents that exists within a range from a specific point:
457+ /// </summary>
458+ public BaseFilter GeoShape ( Expression < Func < T , object > > fieldDescriptor , Action < GeoShapeFilterDescriptor > filterDescriptor )
459+ {
460+ var field = new PropertyNameResolver ( ) . Resolve ( fieldDescriptor ) ;
461+ return this . GeoShape ( field , filterDescriptor ) ;
462+ }
463+ /// <summary>
464+ /// Filters documents that exists within a range from a specific point:
465+ /// </summary>
466+ public BaseFilter GeoShape ( string field , Action < GeoShapeFilterDescriptor > filterDescriptor )
467+ {
468+ var filter = new GeoShapeFilterDescriptor ( ) ;
469+ if ( filterDescriptor == null )
470+ return CreateConditionlessFilterDescriptor ( "geo_shape" , filter ) ;
471+
472+ filterDescriptor ( filter ) ;
473+ if ( filter . IsConditionless )
474+ return CreateConditionlessFilterDescriptor ( "geo_shape" , filter ) ;
475+
476+ return this . SetDictionary ( "geo_shape" , field , filter , ( d , b ) =>
477+ {
478+ b . GeoShapeFilter = d ;
479+ } ) ;
454480
455481 }
482+
456483 /// <summary>
457484 /// A filter allowing to include hits that only fall within a polygon of points.
458485 /// </summary>
0 commit comments