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
  • Loading branch information
russcam authored Apr 17, 2020
2 parents 763ed83 + 79003da commit aff2c93
Show file tree
Hide file tree
Showing 4 changed files with 274 additions and 25 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
Loading

0 comments on commit aff2c93

Please sign in to comment.