Geo Distance Query Usage

edit

Fluent DSL example

edit
q
.GeoDistance(g => g
    .Boost(1.1)
    .Name("named_query")
    .Field(p => p.LocationPoint)
    .DistanceType(GeoDistanceType.Arc)
    .Location(34, -34)
    .Distance("200m")
    .ValidationMethod(GeoValidationMethod.IgnoreMalformed)
    .IgnoreUnmapped(true)
)

Object Initializer syntax example

edit
new GeoDistanceQuery
{
    Boost = 1.1,
    Name = "named_query",
    Field = Infer.Field<Project>(p => p.LocationPoint),
    DistanceType = GeoDistanceType.Arc,
    Location = new GeoLocation(34, -34),
    Distance = "200m",
    ValidationMethod = GeoValidationMethod.IgnoreMalformed,
    IgnoreUnmapped = true,
}

Example json output.

{
  "geo_distance": {
    "_name": "named_query",
    "boost": 1.1,
    "distance": "200m",
    "distance_type": "arc",
    "validation_method": "ignore_malformed",
    "locationPoint": {
      "lat": 34.0,
      "lon": -34.0
    },
    "ignore_unmapped": true
  }
}