I'm trying to create a geo_shape query that will be used in a runtime field to tag a polygon 'id/name' to a point that it contains. I have two pre-indexed indexes: one for neighborhoods (polygon) and one for car crashes (point) and would like the car crash index to be tagged via a runtime query field with the neighborhood name that it is located in. - so every new crash doc gets its neighborhood associated with it.
I feel that I'm close to getting it, but still getting errors after trying for a long while, I thought I reach out for help. Below is the query that I'm testing with. 'neighs' = polygon index for neighborhoods and 'crash' = point index. It returns a Illegal argument exception, Required [type] error. I've tried to add a type in the query in various ways (point, _doc, polygon, etc) to no avail.
The geometry/coord fields for neighs is called: 'geometry' and 'location' for the crash point coords.
Thanks for your help!
GET neighs/_search
{
"query": {
"bool": {
"filter": {
"geo_shape": {
"location": {
"indexed_shape": {
"index": "crash",
"type": "point",
"id": "ADI497001X",
"path": "location"
}
}
}
}
}
}
}
Here's an example of a neighborhood indexed doc:
{
"_index": "neighs",
"_id": "gcy52oQBjjcu_kHT5h28",
"_score": 1,
"_source": {
"Shape_STAr": 0.0000197467779799,
"Population": 889,
"geometry": {
"coordinates": [
[
[
-76.60941,
39.325561
],
[
-76.609407,
39.325799
],
etc......
],
"type": "Polygon"
},
"Name": "Abell"
}
},
And here is a 'crash' indexed doc:
{
"_index": "crash",
"_id": "ADH56700B2",
"_score": 1,
"_ignored": [
"narrative.keyword"
],
"_source": {
"@timestamp": "2023-04-06T18:00:12.026635Z",
"crashdate": "2023-03-29T04:00:00Z",
"location": {
"lon": -76.6407616882842,
"lat": 39.3155478455349
},
"reporttype_type": "Property Damage : Vehicle",
"source": "ACRS",
"type": "Vehicle"
}
},