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.LocationShape)
    .IndexedShape(p => p
        .Id(Project.Instance.Name)
        .Path(pp => pp.LocationShape)
        .Routing(Project.Instance.Name)
    )
    .Relation(GeoShapeRelation.Intersects)
)

Object Initializer syntax exampleedit

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

Example json output.

{
  "geo_shape": {
    "_name": "named_query",
    "boost": 1.1,
    "locationShape": {
      "indexed_shape": {
        "id": "Durgan LLC",
        "index": "project",
        "type": "doc",
        "path": "locationShape",
        "routing": "Durgan LLC"
      },
      "relation": "intersects"
    }
  }
}