Geo Polygon Query Usage

edit

Fluent DSL example

edit
q
.GeoPolygon(c => c
    .Name("named_query")
    .Boost(1.1)
    .Field(p => p.LocationPoint)
    .ValidationMethod(GeoValidationMethod.Strict)
    .Points(new GeoLocation(45, -45), new GeoLocation(-34, 34), new GeoLocation(70, -70))
)

Object Initializer syntax example

edit
new GeoPolygonQuery
{
    Boost = 1.1,
    Name = "named_query",
    ValidationMethod = GeoValidationMethod.Strict,
    Points = new[] { new GeoLocation(45, -45), new GeoLocation(-34, 34), new GeoLocation(70, -70) },
    Field = Infer.Field<Project>(p => p.LocationPoint)
}

Example json output.

{
  "geo_polygon": {
    "_name": "named_query",
    "boost": 1.1,
    "validation_method": "strict",
    "locationPoint": {
      "points": [
        {
          "lat": 45.0,
          "lon": -45.0
        },
        {
          "lat": -34.0,
          "lon": 34.0
        },
        {
          "lat": 70.0,
          "lon": -70.0
        }
      ]
    }
  }
}