Geo Shape Polygon Query Usage

edit

Fluent DSL example

edit
q
.GeoShapePolygon(c => c
    .Name("named_query")
    .Boost(1.1)
    .Field(p => p.LocationShape)
    .Coordinates(PolygonCoordinates)
    .Relation(GeoShapeRelation.Intersects)
    .IgnoreUnmapped(true)
)

Object Initializer syntax example

edit
new GeoShapePolygonQuery
{
    Name = "named_query",
    Boost = 1.1,
    Field = Field<Project>(p => p.LocationShape),
    Shape = new PolygonGeoShape(PolygonCoordinates),
    Relation = GeoShapeRelation.Intersects,
    IgnoreUnmapped = true
}

Example json output.

{
  "geo_shape": {
    "_name": "named_query",
    "boost": 1.1,
    "ignore_unmapped": true,
    "locationShape": {
      "relation": "intersects",
      "shape": {
        "type": "polygon",
        "coordinates": [
          [
            [
              10.0,
              -17.0
            ],
            [
              15.0,
              16.0
            ],
            [
              0.0,
              12.0
            ],
            [
              -15.0,
              16.0
            ],
            [
              -10.0,
              -17.0
            ],
            [
              10.0,
              -17.0
            ]
          ],
          [
            [
              8.2,
              18.2
            ],
            [
              8.2,
              -18.8
            ],
            [
              -8.8,
              -10.8
            ],
            [
              8.8,
              18.2
            ]
          ]
        ]
      }
    }
  }
}