Skip to content

Commit 1ff2e68

Browse files
committed
Add relation to geoshape filters
Closes #1090
1 parent 9bd70c8 commit 1ff2e68

12 files changed

+127
-12
lines changed

src/Nest/DSL/Filter/GeoIndexedShapeFilterDescriptor.cs

+8
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ protected internal override void WrapInContainer(IFilterContainer container)
2424
public PropertyPathMarker Field { get; set; }
2525

2626
public IndexedGeoShape IndexedShape { get; set; }
27+
28+
public GeoShapeRelation? Relation { get; set; }
2729
}
2830

2931
public class GeoIndexedShapeFilterDescriptor : FilterBase, IGeoIndexedShapeFilter
@@ -38,6 +40,7 @@ bool IFilter.IsConditionless
3840
}
3941

4042
PropertyPathMarker IFieldNameFilter.Field { get; set; }
43+
GeoShapeRelation? IGeoShapeBaseFilter.Relation { get; set; }
4144
IndexedGeoShape IGeoIndexedShapeFilter.IndexedShape { get; set; }
4245

4346
public GeoIndexedShapeFilterDescriptor Lookup<T>(string field, string id, string index = null, string type = null)
@@ -62,6 +65,11 @@ public GeoIndexedShapeFilterDescriptor Lookup<T>(Expression<Func<T, object>> fie
6265
return _SetShape<T>(field, id, index, type);
6366
}
6467

68+
public GeoIndexedShapeFilterDescriptor Relation<T>(GeoShapeRelation relation)
69+
{
70+
((IGeoIndexedShapeFilter)this).Relation = relation;
71+
return this;
72+
}
6573
}
6674

6775
}

src/Nest/DSL/Filter/GeoShapeCircleFilterDescriptor.cs

+9
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ protected internal override void WrapInContainer(IFilterContainer container)
2727
public PropertyPathMarker Field { get; set; }
2828

2929
public ICircleGeoShape Shape { get; set; }
30+
31+
public GeoShapeRelation? Relation { get; set; }
3032
}
3133

3234
public class GeoShapeCircleFilterDescriptor : FilterBase, IGeoShapeCircleFilter
@@ -42,6 +44,7 @@ bool IFilter.IsConditionless
4244
}
4345

4446
PropertyPathMarker IFieldNameFilter.Field { get; set; }
47+
GeoShapeRelation? IGeoShapeBaseFilter.Relation { get; set; }
4548
ICircleGeoShape IGeoShapeCircleFilter.Shape { get; set; }
4649

4750
public GeoShapeCircleFilterDescriptor Coordinates(IEnumerable<double> coordinates)
@@ -59,6 +62,12 @@ public GeoShapeCircleFilterDescriptor Radius(string radius)
5962
this.Self.Shape.Radius = radius;
6063
return this;
6164
}
65+
66+
public GeoShapeCircleFilterDescriptor Relation(GeoShapeRelation relation)
67+
{
68+
this.Self.Relation = relation;
69+
return this;
70+
}
6271
}
6372

6473
}

src/Nest/DSL/Filter/GeoShapeEnvelopeFilterDescriptor.cs

+11
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ namespace Nest
1313
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
1414
public interface IGeoShapeBaseFilter : IFieldNameFilter
1515
{
16+
[JsonProperty("relation")]
17+
GeoShapeRelation? Relation { get; set; }
1618
}
1719

1820
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
@@ -32,6 +34,8 @@ protected internal override void WrapInContainer(IFilterContainer container)
3234
public PropertyPathMarker Field { get; set; }
3335

3436
public IEnvelopeGeoShape Shape { get; set; }
37+
38+
public GeoShapeRelation? Relation { get; set; }
3539
}
3640

3741
public class GeoShapeEnvelopeFilterDescriptor : FilterBase, IGeoShapeEnvelopeFilter
@@ -47,6 +51,7 @@ bool IFilter.IsConditionless
4751
}
4852

4953
PropertyPathMarker IFieldNameFilter.Field { get; set; }
54+
GeoShapeRelation? IGeoShapeBaseFilter.Relation { get; set; }
5055
IEnvelopeGeoShape IGeoShapeEnvelopeFilter.Shape { get; set; }
5156

5257
public GeoShapeEnvelopeFilterDescriptor Coordinates(IEnumerable<IEnumerable<double>> coordinates)
@@ -56,6 +61,12 @@ public GeoShapeEnvelopeFilterDescriptor Coordinates(IEnumerable<IEnumerable<doub
5661
this.Self.Shape.Coordinates = coordinates;
5762
return this;
5863
}
64+
65+
public GeoShapeEnvelopeFilterDescriptor Relation(GeoShapeRelation relation)
66+
{
67+
this.Self.Relation = relation;
68+
return this;
69+
}
5970
}
6071

6172
}

src/Nest/DSL/Filter/GeoShapeLineStringFilterDescriptor.cs

+8-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ protected internal override void WrapInContainer(IFilterContainer container)
2525
}
2626

2727
public PropertyPathMarker Field { get; set; }
28-
28+
public GeoShapeRelation? Relation { get; set; }
2929
public ILineStringGeoShape Shape { get; set; }
3030
}
3131

@@ -42,6 +42,7 @@ bool IFilter.IsConditionless
4242
}
4343

4444
PropertyPathMarker IFieldNameFilter.Field { get; set; }
45+
GeoShapeRelation? IGeoShapeBaseFilter.Relation { get; set; }
4546
ILineStringGeoShape IGeoShapeLineStringFilter.Shape { get; set; }
4647

4748
public GeoShapeLineStringFilterDescriptor Coordinates(IEnumerable<IEnumerable<double>> coordinates)
@@ -51,6 +52,12 @@ public GeoShapeLineStringFilterDescriptor Coordinates(IEnumerable<IEnumerable<do
5152
this.Self.Shape.Coordinates = coordinates;
5253
return this;
5354
}
55+
56+
public GeoShapeLineStringFilterDescriptor Relation(GeoShapeRelation relation)
57+
{
58+
this.Self.Relation = relation;
59+
return this;
60+
}
5461
}
5562

5663
}

src/Nest/DSL/Filter/GeoShapeMultiLineStringFilterDescriptor.cs

+9
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ protected internal override void WrapInContainer(IFilterContainer container)
2626

2727
public PropertyPathMarker Field { get; set; }
2828

29+
public GeoShapeRelation? Relation { get; set; }
30+
2931
public IMultiLineStringGeoShape Shape { get; set; }
3032
}
3133

@@ -42,6 +44,7 @@ bool IFilter.IsConditionless
4244
}
4345

4446
PropertyPathMarker IFieldNameFilter.Field { get; set; }
47+
GeoShapeRelation? IGeoShapeBaseFilter.Relation { get; set; }
4548
IMultiLineStringGeoShape IGeoShapeMultiLineStringFilter.Shape { get; set; }
4649

4750
public GeoShapeMultiLineStringFilterDescriptor Coordinates(IEnumerable<IEnumerable<IEnumerable<double>>> coordinates)
@@ -51,6 +54,12 @@ public GeoShapeMultiLineStringFilterDescriptor Coordinates(IEnumerable<IEnumerab
5154
this.Self.Shape.Coordinates = coordinates;
5255
return this;
5356
}
57+
58+
public GeoShapeMultiLineStringFilterDescriptor Relation(GeoShapeRelation relation)
59+
{
60+
this.Self.Relation = relation;
61+
return this;
62+
}
5463
}
5564

5665
}

src/Nest/DSL/Filter/GeoShapeMultiPointFilterDescriptor.cs

+9
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ protected internal override void WrapInContainer(IFilterContainer container)
2626

2727
public PropertyPathMarker Field { get; set; }
2828

29+
public GeoShapeRelation? Relation { get; set; }
30+
2931
public IMultiPointGeoShape Shape { get; set; }
3032
}
3133

@@ -42,6 +44,7 @@ bool IFilter.IsConditionless
4244
}
4345

4446
PropertyPathMarker IFieldNameFilter.Field { get; set; }
47+
GeoShapeRelation? IGeoShapeBaseFilter.Relation { get; set; }
4548
IMultiPointGeoShape IGeoShapeMultiPointFilter.Shape { get; set; }
4649

4750
public GeoShapeMultiPointFilterDescriptor Coordinates(IEnumerable<IEnumerable<double>> coordinates)
@@ -51,6 +54,12 @@ public GeoShapeMultiPointFilterDescriptor Coordinates(IEnumerable<IEnumerable<do
5154
this.Self.Shape.Coordinates = coordinates;
5255
return this;
5356
}
57+
58+
public GeoShapeMultiPointFilterDescriptor Relation(GeoShapeRelation relation)
59+
{
60+
this.Self.Relation = relation;
61+
return this;
62+
}
5463
}
5564

5665
}

src/Nest/DSL/Filter/GeoShapeMultiPolygonFilterDescriptor.cs

+9
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ protected internal override void WrapInContainer(IFilterContainer container)
2626

2727
public PropertyPathMarker Field { get; set; }
2828

29+
public GeoShapeRelation? Relation { get; set; }
30+
2931
public IMultiPolygonGeoShape Shape { get; set; }
3032
}
3133

@@ -42,6 +44,7 @@ bool IFilter.IsConditionless
4244
}
4345

4446
PropertyPathMarker IFieldNameFilter.Field { get; set; }
47+
GeoShapeRelation? IGeoShapeBaseFilter.Relation { get; set; }
4548
IMultiPolygonGeoShape IGeoShapeMultiPolygonFilter.Shape { get; set; }
4649

4750
public GeoShapeMultiPolygonFilterDescriptor Coordinates(IEnumerable<IEnumerable<IEnumerable<IEnumerable<double>>>> coordinates)
@@ -51,6 +54,12 @@ public GeoShapeMultiPolygonFilterDescriptor Coordinates(IEnumerable<IEnumerable<
5154
this.Self.Shape.Coordinates = coordinates;
5255
return this;
5356
}
57+
58+
public GeoShapeMultiPolygonFilterDescriptor Relation(GeoShapeRelation relation)
59+
{
60+
this.Self.Relation = relation;
61+
return this;
62+
}
5463
}
5564

5665
}

src/Nest/DSL/Filter/GeoShapePointFilterDescriptor.cs

+8-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ protected internal override void WrapInContainer(IFilterContainer container)
2525
}
2626

2727
public PropertyPathMarker Field { get; set; }
28-
28+
public GeoShapeRelation? Relation { get; set; }
2929
public IPointGeoShape Shape { get; set; }
3030
}
3131

@@ -42,6 +42,7 @@ bool IFilter.IsConditionless
4242
}
4343

4444
PropertyPathMarker IFieldNameFilter.Field { get; set; }
45+
GeoShapeRelation? IGeoShapeBaseFilter.Relation { get; set; }
4546
IPointGeoShape IGeoShapePointFilter.Shape { get; set; }
4647

4748
public GeoShapePointFilterDescriptor Coordinates(IEnumerable<double> coordinates)
@@ -51,6 +52,12 @@ public GeoShapePointFilterDescriptor Coordinates(IEnumerable<double> coordinates
5152
this.Self.Shape.Coordinates = coordinates;
5253
return this;
5354
}
55+
56+
public GeoShapePointFilterDescriptor Relation(GeoShapeRelation relation)
57+
{
58+
this.Self.Relation = relation;
59+
return this;
60+
}
5461
}
5562

5663
}

src/Nest/DSL/Filter/GeoShapePolygonFilterDescriptor.cs

+8-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ protected internal override void WrapInContainer(IFilterContainer container)
2525
}
2626

2727
public PropertyPathMarker Field { get; set; }
28-
28+
public GeoShapeRelation? Relation { get; set; }
2929
public IPolygonGeoShape Shape { get; set; }
3030
}
3131

@@ -42,6 +42,7 @@ bool IFilter.IsConditionless
4242
}
4343

4444
PropertyPathMarker IFieldNameFilter.Field { get; set; }
45+
GeoShapeRelation? IGeoShapeBaseFilter.Relation { get; set; }
4546
IPolygonGeoShape IGeoShapePolygonFilter.Shape { get; set; }
4647

4748
public GeoShapePolygonFilterDescriptor Coordinates(IEnumerable<IEnumerable<IEnumerable<double>>> coordinates)
@@ -51,6 +52,12 @@ public GeoShapePolygonFilterDescriptor Coordinates(IEnumerable<IEnumerable<IEnum
5152
this.Self.Shape.Coordinates = coordinates;
5253
return this;
5354
}
55+
56+
public GeoShapePolygonFilterDescriptor Relation(GeoShapeRelation relation)
57+
{
58+
this.Self.Relation = relation;
59+
return this;
60+
}
5461
}
5562

5663
}

src/Nest/Enums/GeoShapeRelation.cs

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using Newtonsoft.Json;
2+
using Newtonsoft.Json.Converters;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Runtime.Serialization;
7+
using System.Text;
8+
9+
namespace Nest
10+
{
11+
[JsonConverter(typeof(StringEnumConverter))]
12+
public enum GeoShapeRelation
13+
{
14+
[EnumMember(Value = "intersects")]
15+
Intersects,
16+
[EnumMember(Value = "disjoint")]
17+
Disjoint,
18+
[EnumMember(Value = "within")]
19+
Within
20+
}
21+
}

src/Nest/Nest.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@
369369
<Compile Include="Enums\FieldDataLoading.cs" />
370370
<Compile Include="Enums\FieldDataNonStringFormat.cs" />
371371
<Compile Include="Enums\FieldDataStringFormat.cs" />
372+
<Compile Include="Enums\GeoShapeRelation.cs" />
372373
<Compile Include="Enums\HighlighterType.cs" />
373374
<Compile Include="Enums\NormsLoading.cs" />
374375
<Compile Include="Enums\RoutingAllocationEnableOption.cs" />

0 commit comments

Comments
 (0)