Skip to content

Commit

Permalink
Merge pull request #4601 from elastic/feature/circle-multipoint-support
Browse files Browse the repository at this point in the history
Integration tests and docs for circle and multipoint geoshape queries

(cherry picked from commit aff2c93)
  • Loading branch information
russcam committed Apr 17, 2020
1 parent 7f3bf4d commit accc800
Show file tree
Hide file tree
Showing 4 changed files with 375 additions and 4 deletions.
121 changes: 121 additions & 0 deletions docs/query-dsl/geo/geo-shape/geo-shape-query-usage.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,69 @@ new GeoShapeQuery
}
----

[[geo-shape-query-multipoint]]
[float]
== Querying with MultiPoint

NOTE: Elasticsearch 7.7.0+ required when MultiPoint is indexed using BKD trees (the default).

==== Fluent DSL example

[source,csharp]
----
q
.GeoShape(c => c
.Name("named_query")
.Boost(1.1)
.Field(p => p.LocationShape)
.Shape(s => s
.MultiPoint(MultiPointCoordinates)
)
.Relation(GeoShapeRelation.Intersects)
)
----

==== Object Initializer syntax example

[source,csharp]
----
new GeoShapeQuery
{
Name = "named_query",
Boost = 1.1,
Field = Infer.Field<Project>(p => p.LocationShape),
Shape = new MultiPointGeoShape(MultiPointCoordinates),
Relation = GeoShapeRelation.Intersects,
}
----

[source,javascript]
.Example json output
----
{
"geo_shape": {
"_name": "named_query",
"boost": 1.1,
"locationShape": {
"relation": "intersects",
"shape": {
"type": "multipoint",
"coordinates": [
[
38.897676,
-77.03653
],
[
38.889939,
-77.009051
]
]
}
}
}
}
----

[[geo-shape-query-linestring]]
[float]
== Querying with LineString
Expand Down Expand Up @@ -823,6 +886,64 @@ new GeoShapeQuery
}
----

[[geo-shape-query-circle]]
[float]
== Querying with Circle

NOTE: Available in Elasticsearch 7.7.0+

==== Fluent DSL example

[source,csharp]
----
q
.GeoShape(c => c
.Name("named_query")
.Boost(1.1)
.Field(p => p.LocationShape)
.Shape(s => s
.Circle(CircleCoordinates, "100m")
)
.Relation(GeoShapeRelation.Intersects)
)
----

==== Object Initializer syntax example

[source,csharp]
----
new GeoShapeQuery
{
Name = "named_query",
Boost = 1.1,
Field = Infer.Field<Project>(p => p.LocationShape),
Shape = new CircleGeoShape(CircleCoordinates, "100m"),
Relation = GeoShapeRelation.Intersects,
}
----

[source,javascript]
.Example json output
----
{
"geo_shape": {
"_name": "named_query",
"boost": 1.1,
"locationShape": {
"relation": "intersects",
"shape": {
"type": "circle",
"radius": "100m",
"coordinates": [
45.0,
-45.0
]
}
}
}
}
----

[[geo-shape-query-indexedshape]]
[float]
== Querying with an indexed shape
Expand Down
121 changes: 121 additions & 0 deletions docs/query-dsl/specialized/shape/shape-query-usage.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,69 @@ new ShapeQuery
}
----

[[shape-query-multipoint]]
[float]
== Querying with MultiPoint

NOTE: Elasticsearch 7.7.0+ required when MultiPoint is indexed using BKD trees (the default).

==== Fluent DSL example

[source,csharp]
----
q
.Shape(c => c
.Name("named_query")
.Boost(1.1)
.Field(p => p.ArbitraryShape)
.Shape(s => s
.MultiPoint(MultiPointCoordinates)
)
.Relation(ShapeRelation.Intersects)
)
----

==== Object Initializer syntax example

[source,csharp]
----
new ShapeQuery
{
Name = "named_query",
Boost = 1.1,
Field = Infer.Field<Project>(p => p.ArbitraryShape),
Shape = new MultiPointGeoShape(MultiPointCoordinates),
Relation = ShapeRelation.Intersects,
}
----

[source,javascript]
.Example json output
----
{
"shape": {
"_name": "named_query",
"boost": 1.1,
"arbitraryShape": {
"relation": "intersects",
"shape": {
"type": "multipoint",
"coordinates": [
[
38.897676,
-77.03653
],
[
38.889939,
-77.009051
]
]
}
}
}
}
----

[[shape-query-linestring]]
[float]
== Querying with LineString
Expand Down Expand Up @@ -820,6 +883,64 @@ new ShapeQuery
}
----

[[shape-query-circle]]
[float]
== Querying with Circle

NOTE: Available in Elasticsearch 7.7.0+

==== Fluent DSL example

[source,csharp]
----
q
.Shape(c => c
.Name("named_query")
.Boost(1.1)
.Field(p => p.ArbitraryShape)
.Shape(s => s
.Circle(CircleCoordinates, "100m")
)
.Relation(ShapeRelation.Intersects)
)
----

==== Object Initializer syntax example

[source,csharp]
----
new ShapeQuery
{
Name = "named_query",
Boost = 1.1,
Field = Infer.Field<Project>(p => p.ArbitraryShape),
Shape = new CircleGeoShape(CircleCoordinates, "100m"),
Relation = ShapeRelation.Intersects,
}
----

[source,javascript]
.Example json output
----
{
"shape": {
"_name": "named_query",
"boost": 1.1,
"arbitraryShape": {
"relation": "intersects",
"shape": {
"type": "circle",
"radius": "100m",
"coordinates": [
45.0,
-45.0
]
}
}
}
}
----

[[shape-query-indexedshape]]
[float]
== Querying with an indexed shape
Expand Down
20 changes: 16 additions & 4 deletions tests/Tests/QueryDsl/Geo/GeoShape/GeoShapeQueryUsageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,14 @@ protected override QueryContainer QueryFluent(QueryContainerDescriptor<Project>
);
}

// hide
[SkipVersion(">=7.0.0", "multipoint queries are not supported")]
/**
* [float]
* [[geo-shape-query-multipoint]]
* == Querying with MultiPoint
*
* NOTE: Elasticsearch 7.7.0+ required when MultiPoint is indexed using BKD trees (the default).
*/
[SkipVersion("<7.7.0", "multipoint queries are supported from 7.7.0 onwards")]
public class GeoShapeMultiPointQueryUsageTests : GeoShapeQueryUsageTestsBase
{
public GeoShapeMultiPointQueryUsageTests(ReadOnlyCluster i, EndpointUsage usage) : base(i, usage) { }
Expand Down Expand Up @@ -593,8 +599,14 @@ protected override QueryContainer QueryFluent(QueryContainerDescriptor<Project>
);
}

// hide
[SkipVersion(">=7.0.0", "CIRCLE geometry is not supported. See https://github.com/elastic/elasticsearch/issues/39237")]
/**
* [float]
* [[geo-shape-query-circle]]
* == Querying with Circle
*
* NOTE: Available in Elasticsearch 7.7.0+
*/
[SkipVersion("<7.7.0", "CIRCLE geometry is supported from 7.7.0+. See https://github.com/elastic/elasticsearch/issues/39237")]
public class GeoShapeCircleQueryUsageTests : GeoShapeQueryUsageTestsBase
{
public GeoShapeCircleQueryUsageTests(ReadOnlyCluster i, EndpointUsage usage) : base(i, usage) { }
Expand Down
Loading

0 comments on commit accc800

Please sign in to comment.