Geo Distance Range Query Usage

edit

Fluent DSL example

edit
q
.GeoDistanceRange(g=>g
    .Boost(1.1)
    .Name("named_query")
    .Field(p=>p.Location)
    .DistanceType(GeoDistanceType.Arc)
    .Coerce()
    .GreaterThanOrEqualTo(200, DistanceUnit.Kilometers)
    .GreaterThan(200, DistanceUnit.Kilometers)
    .IgnoreMalformed()
    .Location(new GeoLocation(40, -70))
    .Optimize(GeoOptimizeBBox.Indexed)
    .LessThanOrEqualTo(Nest.Distance.Miles(400))
    .LessThan(Nest.Distance.Miles(400))
    .ValidationMethod(GeoValidationMethod.Strict)
)

Object Initializer syntax example

edit
new GeoDistanceRangeQuery
{
    Boost = 1.1,
    Name = "named_query",
    Field = Infer.Field<Project>(p=>p.Location),
    DistanceType = GeoDistanceType.Arc,
    Coerce = true,
    GreaterThanOrEqualTo = Nest.Distance.Kilometers(200),
    IgnoreMalformed = true,
    GreaterThan = Nest.Distance.Kilometers(200),
    LessThan = Nest.Distance.Miles(400),
    Location = new GeoLocation(40, -70),
    OptimizeBoundingBox = GeoOptimizeBBox.Indexed,
    LessThanOrEqualTo = Nest.Distance.Miles(400),
    ValidationMethod = GeoValidationMethod.Strict
}

Example json output.

{
  "geo_distance_range": {
    "gt": "200.0km",
    "gte": "200.0km",
    "lt": "400.0mi",
    "lte": "400.0mi",
    "distance_type": "arc",
    "optimize_bbox": "indexed",
    "coerce": true,
    "ignore_malformed": true,
    "validation_method": "strict",
    "_name": "named_query",
    "boost": 1.1,
    "location": {
      "lat": 40.0,
      "lon": -70.0
    }
  }
}