Skip to content

Commit df3e78f

Browse files
committed
Merge branch 'fix/geoshape' into develop
Conflicts: src/Nest/Nest.csproj
2 parents 2593b94 + ba869b6 commit df3e78f

File tree

59 files changed

+2932
-191
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+2932
-191
lines changed

src/Nest/DSL/Filter/FilterDescriptor.cs

Lines changed: 185 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -257,26 +257,202 @@ private FilterContainer _GeoDistanceRange(PropertyPathMarker field, Action<GeoDi
257257
}
258258

259259
/// <summary>
260-
/// Filter documents indexed using the geo_shape type.
260+
/// Filter documents indexed using the circle geo_shape type.
261261
/// </summary>
262-
public FilterContainer GeoShape(Expression<Func<T, object>> fieldDescriptor, Action<GeoShapeFilterDescriptor> filterDescriptor)
262+
public FilterContainer GeoShapeCircle(Expression<Func<T, object>> fieldDescriptor, Action<GeoShapeCircleFilterDescriptor> filterDescriptor)
263263
{
264-
return _GeoShape(fieldDescriptor, filterDescriptor);
264+
return _GeoShapeCircle(fieldDescriptor, filterDescriptor);
265265
}
266266
/// <summary>
267-
/// Filter documents indexed using the geo_shape type.
267+
/// Filter documents indexed using the circle geo_shape type.
268+
/// </summary>
269+
public FilterContainer GeoShapeCircle(string field, Action<GeoShapeCircleFilterDescriptor> filterDescriptor)
270+
{
271+
return _GeoShapeCircle(field, filterDescriptor);
272+
}
273+
274+
private FilterContainer _GeoShapeCircle(PropertyPathMarker field, Action<GeoShapeCircleFilterDescriptor> filterDescriptor)
275+
{
276+
var filter = new GeoShapeCircleFilterDescriptor();
277+
if (filterDescriptor != null)
278+
filterDescriptor(filter);
279+
((IGeoShapeCircleFilter)filter).Field = field;
280+
return this.New(filter, f => f.GeoShape = filter);
281+
}
282+
283+
/// <summary>
284+
/// Filter documents indexed using the envelope geo_shape type.
285+
/// </summary>
286+
public FilterContainer GeoShapeEnvelope(Expression<Func<T, object>> fieldDescriptor, Action<GeoShapeEnvelopeFilterDescriptor> filterDescriptor)
287+
{
288+
return _GeoShapeEnvelope(fieldDescriptor, filterDescriptor);
289+
}
290+
291+
/// <summary>
292+
/// Filter documents indexed using the envelope geo_shape type.
293+
/// </summary>
294+
public FilterContainer GeoShapeEnvelope(string field, Action<GeoShapeEnvelopeFilterDescriptor> filterDescriptor)
295+
{
296+
return _GeoShapeEnvelope(field, filterDescriptor);
297+
}
298+
299+
private FilterContainer _GeoShapeEnvelope(PropertyPathMarker field, Action<GeoShapeEnvelopeFilterDescriptor> filterDescriptor)
300+
{
301+
var filter = new GeoShapeEnvelopeFilterDescriptor();
302+
if (filterDescriptor != null)
303+
filterDescriptor(filter);
304+
((IGeoShapeEnvelopeFilter)filter).Field = field;
305+
return this.New(filter, f => f.GeoShape = filter);
306+
}
307+
308+
/// <summary>
309+
/// Filter documents indexed using the linestring geo_shape type.
310+
/// </summary>
311+
public FilterContainer GeoShapeLineString(Expression<Func<T, object>> fieldDescriptor, Action<GeoShapeLineStringFilterDescriptor> filterDescriptor)
312+
{
313+
return _GeoShapeLineString(fieldDescriptor, filterDescriptor);
314+
}
315+
316+
/// <summary>
317+
/// Filter documents indexed using the linestring geo_shape type.
318+
/// </summary>
319+
public FilterContainer GeoShapeLineString(string field, Action<GeoShapeLineStringFilterDescriptor> filterDescriptor)
320+
{
321+
return _GeoShapeLineString(field, filterDescriptor);
322+
}
323+
324+
private FilterContainer _GeoShapeLineString(PropertyPathMarker field, Action<GeoShapeLineStringFilterDescriptor> filterDescriptor)
325+
{
326+
var filter = new GeoShapeLineStringFilterDescriptor();
327+
if (filterDescriptor != null)
328+
filterDescriptor(filter);
329+
((IGeoShapeLineStringFilter)filter).Field = field;
330+
return this.New(filter, f => f.GeoShape = filter);
331+
}
332+
333+
/// <summary>
334+
/// Filter documents indexed using the multilinestring geo_shape type.
335+
/// </summary>
336+
public FilterContainer GeoShapeMultiLineString(Expression<Func<T, object>> fieldDescriptor, Action<GeoShapeMultiLineStringFilterDescriptor> filterDescriptor)
337+
{
338+
return _GeoShapeMultiLineString(fieldDescriptor, filterDescriptor);
339+
}
340+
341+
/// <summary>
342+
/// Filter documents indexed using the multilinestring geo_shape type.
343+
/// </summary>
344+
public FilterContainer GeoShapeMultiLineString(string field, Action<GeoShapeMultiLineStringFilterDescriptor> filterDescriptor)
345+
{
346+
return _GeoShapeMultiLineString(field, filterDescriptor);
347+
}
348+
349+
private FilterContainer _GeoShapeMultiLineString(PropertyPathMarker field, Action<GeoShapeMultiLineStringFilterDescriptor> filterDescriptor)
350+
{
351+
var filter = new GeoShapeMultiLineStringFilterDescriptor();
352+
if (filterDescriptor != null)
353+
filterDescriptor(filter);
354+
((IGeoShapeMultiLineStringFilter)filter).Field = field;
355+
return this.New(filter, f => f.GeoShape = filter);
356+
}
357+
358+
/// <summary>
359+
/// Filter documents indexed using the point geo_shape type.
360+
/// </summary>
361+
public FilterContainer GeoShapePoint(Expression<Func<T, object>> fieldDescriptor, Action<GeoShapePointFilterDescriptor> filterDescriptor)
362+
{
363+
return _GeoShapePoint(fieldDescriptor, filterDescriptor);
364+
}
365+
366+
/// <summary>
367+
/// Filter documents indexed using the point geo_shape type.
368+
/// </summary>
369+
public FilterContainer GeoShapePoint(string field, Action<GeoShapePointFilterDescriptor> filterDescriptor)
370+
{
371+
return _GeoShapePoint(field, filterDescriptor);
372+
}
373+
374+
private FilterContainer _GeoShapePoint(PropertyPathMarker field, Action<GeoShapePointFilterDescriptor> filterDescriptor)
375+
{
376+
var filter = new GeoShapePointFilterDescriptor();
377+
if (filterDescriptor != null)
378+
filterDescriptor(filter);
379+
((IGeoShapePointFilter)filter).Field = field;
380+
return this.New(filter, f => f.GeoShape = filter);
381+
}
382+
383+
/// <summary>
384+
/// Filter documents indexed using the multipoint geo_shape type.
385+
/// </summary>
386+
public FilterContainer GeoShapeMultiPoint(Expression<Func<T, object>> fieldDescriptor, Action<GeoShapeMultiPointFilterDescriptor> filterDescriptor)
387+
{
388+
return _GeoShapeMultiPoint(fieldDescriptor, filterDescriptor);
389+
}
390+
391+
/// <summary>
392+
/// Filter documents indexed using the multipoint geo_shape type.
393+
/// </summary>
394+
public FilterContainer GeoShapeMultiPoint(string field, Action<GeoShapeMultiPointFilterDescriptor> filterDescriptor)
395+
{
396+
return _GeoShapeMultiPoint(field, filterDescriptor);
397+
}
398+
399+
private FilterContainer _GeoShapeMultiPoint(PropertyPathMarker field, Action<GeoShapeMultiPointFilterDescriptor> filterDescriptor)
400+
{
401+
var filter = new GeoShapeMultiPointFilterDescriptor();
402+
if (filterDescriptor != null)
403+
filterDescriptor(filter);
404+
((IGeoShapeMultiPointFilter)filter).Field = field;
405+
return this.New(filter, f => f.GeoShape = filter);
406+
}
407+
408+
409+
/// <summary>
410+
/// Filter documents indexed using the polygon geo_shape type.
411+
/// </summary>
412+
public FilterContainer GeoShapePolygon(Expression<Func<T, object>> fieldDescriptor, Action<GeoShapePolygonFilterDescriptor> filterDescriptor)
413+
{
414+
return _GeoShapePolygon(fieldDescriptor, filterDescriptor);
415+
}
416+
417+
/// <summary>
418+
/// Filter documents indexed using the polygon geo_shape type.
419+
/// </summary>
420+
public FilterContainer GeoShapePolygon(string field, Action<GeoShapePolygonFilterDescriptor> filterDescriptor)
421+
{
422+
return _GeoShapePolygon(field, filterDescriptor);
423+
}
424+
425+
private FilterContainer _GeoShapePolygon(PropertyPathMarker field, Action<GeoShapePolygonFilterDescriptor> filterDescriptor)
426+
{
427+
var filter = new GeoShapePolygonFilterDescriptor();
428+
if (filterDescriptor != null)
429+
filterDescriptor(filter);
430+
((IGeoShapePolygonFilter)filter).Field = field;
431+
return this.New(filter, f => f.GeoShape = filter);
432+
}
433+
434+
/// <summary>
435+
/// Filter documents indexed using the multipolygon geo_shape type.
436+
/// </summary>
437+
public FilterContainer GeoShapeMultiPolygon(Expression<Func<T, object>> fieldDescriptor, Action<GeoShapeMultiPolygonFilterDescriptor> filterDescriptor)
438+
{
439+
return _GeoShapeMultiPolygon(fieldDescriptor, filterDescriptor);
440+
}
441+
442+
/// <summary>
443+
/// Filter documents indexed using the multipolygon geo_shape type.
268444
/// </summary>
269-
public FilterContainer GeoShape(string field, Action<GeoShapeFilterDescriptor> filterDescriptor)
445+
public FilterContainer GeoShapeMultiPolygon(string field, Action<GeoShapeMultiPolygonFilterDescriptor> filterDescriptor)
270446
{
271-
return _GeoShape(field, filterDescriptor);
447+
return _GeoShapeMultiPolygon(field, filterDescriptor);
272448
}
273449

274-
private FilterContainer _GeoShape(PropertyPathMarker field, Action<GeoShapeFilterDescriptor> filterDescriptor)
450+
private FilterContainer _GeoShapeMultiPolygon(PropertyPathMarker field, Action<GeoShapeMultiPolygonFilterDescriptor> filterDescriptor)
275451
{
276-
var filter = new GeoShapeFilterDescriptor();
452+
var filter = new GeoShapeMultiPolygonFilterDescriptor();
277453
if (filterDescriptor != null)
278454
filterDescriptor(filter);
279-
((IGeoShapeFilter)filter).Field = field;
455+
((IGeoShapeMultiPolygonFilter)filter).Field = field;
280456
return this.New(filter, f => f.GeoShape = filter);
281457
}
282458

src/Nest/DSL/Filter/GeoIndexedShapeFilterDescriptor.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public interface IGeoIndexedShapeFilter : IGeoShapeBaseFilter
1111
{
1212

1313
[JsonProperty("indexed_shape")]
14-
GeoIndexedShapeVector IndexedShape { get; set; }
14+
IndexedGeoShape IndexedShape { get; set; }
1515
}
1616

1717
public class GeoIndexedShapeFilter : PlainFilter, IGeoIndexedShapeFilter
@@ -23,7 +23,7 @@ protected internal override void WrapInContainer(IFilterContainer container)
2323

2424
public PropertyPathMarker Field { get; set; }
2525

26-
public GeoIndexedShapeVector IndexedShape { get; set; }
26+
public IndexedGeoShape IndexedShape { get; set; }
2727
}
2828

2929
public class GeoIndexedShapeFilterDescriptor : FilterBase, IGeoIndexedShapeFilter
@@ -38,7 +38,7 @@ bool IFilter.IsConditionless
3838
}
3939

4040
PropertyPathMarker IFieldNameFilter.Field { get; set; }
41-
GeoIndexedShapeVector IGeoIndexedShapeFilter.IndexedShape { get; set; }
41+
IndexedGeoShape IGeoIndexedShapeFilter.IndexedShape { get; set; }
4242

4343
public GeoIndexedShapeFilterDescriptor Lookup<T>(string field, string id, string index = null, string type = null)
4444
{
@@ -47,7 +47,7 @@ public GeoIndexedShapeFilterDescriptor Lookup<T>(string field, string id, string
4747

4848
private GeoIndexedShapeFilterDescriptor _SetShape<T>(PropertyPathMarker field, string id, string index, string type)
4949
{
50-
((IGeoIndexedShapeFilter)this).IndexedShape = new GeoIndexedShapeVector
50+
((IGeoIndexedShapeFilter)this).IndexedShape = new IndexedGeoShape
5151
{
5252
Field = field,
5353
Id = id,
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using Nest.Resolvers;
6+
using Nest.Resolvers.Converters;
7+
using Nest.Resolvers.Converters.Filters;
8+
using Newtonsoft.Json;
9+
using Elasticsearch.Net;
10+
11+
namespace Nest
12+
{
13+
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
14+
public interface IGeoShapeCircleFilter : IGeoShapeBaseFilter
15+
{
16+
[JsonProperty("shape")]
17+
ICircleGeoShape Shape { get; set; }
18+
}
19+
20+
public class GeoShapeCircleFilter : PlainFilter, IGeoShapeCircleFilter
21+
{
22+
protected internal override void WrapInContainer(IFilterContainer container)
23+
{
24+
container.GeoShape = this;
25+
}
26+
27+
public PropertyPathMarker Field { get; set; }
28+
29+
public ICircleGeoShape Shape { get; set; }
30+
}
31+
32+
public class GeoShapeCircleFilterDescriptor : FilterBase, IGeoShapeCircleFilter
33+
{
34+
IGeoShapeCircleFilter Self { get { return this; } }
35+
36+
bool IFilter.IsConditionless
37+
{
38+
get
39+
{
40+
return this.Self.Shape == null || !this.Self.Shape.Coordinates.HasAny();
41+
}
42+
}
43+
44+
PropertyPathMarker IFieldNameFilter.Field { get; set; }
45+
ICircleGeoShape IGeoShapeCircleFilter.Shape { get; set; }
46+
47+
public GeoShapeCircleFilterDescriptor Coordinates(IEnumerable<double> coordinates)
48+
{
49+
if (this.Self.Shape == null)
50+
this.Self.Shape = new CircleGeoShape();
51+
this.Self.Shape.Coordinates = coordinates;
52+
return this;
53+
}
54+
55+
public GeoShapeCircleFilterDescriptor Radius(string radius)
56+
{
57+
if (this.Self.Shape == null)
58+
this.Self.Shape = new CircleGeoShape();
59+
this.Self.Shape.Radius = radius;
60+
return this;
61+
}
62+
}
63+
64+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using Nest.Resolvers;
6+
using Nest.Resolvers.Converters;
7+
using Nest.Resolvers.Converters.Filters;
8+
using Newtonsoft.Json;
9+
using Elasticsearch.Net;
10+
11+
namespace Nest
12+
{
13+
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
14+
public interface IGeoShapeBaseFilter : IFieldNameFilter
15+
{
16+
}
17+
18+
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
19+
public interface IGeoShapeEnvelopeFilter : IGeoShapeBaseFilter
20+
{
21+
[JsonProperty("shape")]
22+
IEnvelopeGeoShape Shape { get; set; }
23+
}
24+
25+
public class GeoShapeEnvelopeFilter : PlainFilter, IGeoShapeEnvelopeFilter
26+
{
27+
protected internal override void WrapInContainer(IFilterContainer container)
28+
{
29+
container.GeoShape = this;
30+
}
31+
32+
public PropertyPathMarker Field { get; set; }
33+
34+
public IEnvelopeGeoShape Shape { get; set; }
35+
}
36+
37+
public class GeoShapeEnvelopeFilterDescriptor : FilterBase, IGeoShapeEnvelopeFilter
38+
{
39+
IGeoShapeEnvelopeFilter Self { get { return this; } }
40+
41+
bool IFilter.IsConditionless
42+
{
43+
get
44+
{
45+
return this.Self.Shape == null || !this.Self.Shape.Coordinates.HasAny();
46+
}
47+
}
48+
49+
PropertyPathMarker IFieldNameFilter.Field { get; set; }
50+
IEnvelopeGeoShape IGeoShapeEnvelopeFilter.Shape { get; set; }
51+
52+
public GeoShapeEnvelopeFilterDescriptor Coordinates(IEnumerable<IEnumerable<double>> coordinates)
53+
{
54+
if (this.Self.Shape == null)
55+
this.Self.Shape = new EnvelopeGeoShape();
56+
this.Self.Shape.Coordinates = coordinates;
57+
return this;
58+
}
59+
}
60+
61+
}

0 commit comments

Comments
 (0)