Geo Shape Indexed Shape Query Usageedit

The GeoShape IndexedShape Query supports using a shape which has already been indexed in another index and/or index type within a geoshape query. This is particularly useful for when you have a pre-defined list of shapes which are useful to your application and you want to reference this using a logical name (for example New Zealand), rather than having to provide their coordinates within the request each time.

See the Elasticsearch documentation on geoshape queries for more detail.

Fluent DSL exampleedit

q
.GeoIndexedShape(c => c
    .Name("named_query")
    .Boost(1.1)
    .Field(p=>p.Location)
    .IndexedShape(p=>p
        .Id(2)
        .Path(pp=>pp.Location)
    )
    .Relation(GeoShapeRelation.Intersects)
)

Object Initializer syntax exampleedit

new GeoIndexedShapeQuery
{
    Name = "named_query",
    Boost = 1.1,
    Field = Field<Project>(p=>p.Location),
    IndexedShape = new FieldLookup
    {
        Id = 2,
        Index = Index<Project>(),
        Type = Type<Project>(),
        Path = Field<Project>(p=>p.Location),
    },
    Relation = GeoShapeRelation.Intersects
}

Example json output. 

{
  "geo_shape": {
    "location": {
      "_name": "named_query",
      "boost": 1.1,
      "indexed_shape": {
        "id": 2,
        "type": "project",
        "index": "project",
        "path": "location"
      },
      "relation": "intersects"
    }
  }
}