-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Description
Describe the bug
Can no longer use multiple polygons in geo_shape field.
To Reproduce
Steps to reproduce the behavior:
- Create the following files
run.sh
#!/usr/bin/env bash
printf 'Reset\n'
curl opensearch:9200/entity -X DELETE
printf '\nCreate\n'
curl opensearch:9200/entity -X PUT -d @mapping.json -H "Content-Type: application/json"
printf '\nInsert\n'
curl opensearch:9200/_bulk -X POST --data-binary @data.json -H "Content-Type: application/x-ndjson"
printf '\nRefresh\n'
curl opensearch:9200/entity/_refresh
printf '\nQuery1\n'
curl opensearch:9200/entity/_search?pretty -d @query1.json -H "Content-Type: application/json" > result1.json
printf '\nQuery2\n'
curl opensearch:9200/entity/_search?pretty -d @query2.json -H "Content-Type: application/json" > result2.json
printf '\nQuery3\n'
curl opensearch:9200/entity/_search?pretty -d @query3.json -H "Content-Type: application/json" > result3.json
printf '\n'
mapping.json
{
"mappings": {
"dynamic": "false",
"properties": {
"id": {
"type": "keyword"
},
"polygons": {
"type": "geo_shape"
}
}
}
}data.json
{"update":{"_index":"entity","_id":"e3bb575d-30b9-4793-a92a-91652ffb6e9e"}}
{"doc":{"id":"e3bb575d-30b9-4793-a92a-91652ffb6e9e","polygons":[{"type":"Polygon","coordinates":[[[109,9],[109,8],[110,8],[110,9],[109,9]]]},{"type":"Polygon","coordinates":[[[109,11],[109,10],[110,10],[110,11],[109,11]]]}]},"doc_as_upsert":true}
query1.json
{
"query": {
"bool": {
"filter": {
"geo_shape": {
"polygons": {
"shape": {
"coordinates": [109.5,10.5],
"type": "point"
},
"relation": "intersects"
}
}
}
}
}
}
query2.json
{
"query": {
"bool": {
"filter": {
"geo_shape": {
"polygons": {
"shape": {
"coordinates": [109.5,8.5],
"type": "point"
},
"relation": "intersects"
}
}
}
}
}
}
query3.json
{
"query": {
"bool": {
"filter": {
"geo_shape": {
"polygons": {
"shape": {
"coordinates": [109.5,9.5],
"type": "point"
},
"relation": "intersects"
}
}
}
}
}
}- Ensure opensearch is running and execute
run.sh. - Inspect
result1.json,result2.jsonandresult3.json
Expected behavior
Geo shape with multiple polygons gets indexed and is queryable. Results are as expected. This works in 2.8, but no longer works in 2.9 and fails with the error "DocValuesField \"polygons\" appears more than once in this document (only one value is allowed per field)"
Plugins
None
Host/Environment (please complete the following information):
- OS: Official docker image
opensearchproject/opensearch:2.9.0 - Version 2.9 introduces the issue
Additional context
This possibly wasn't supposed to work to begin with, but it did for a very long time and people are relying on it (we were!). Consider marking this as a breaking change, or at the very least documenting the behaviour change in the changelogs.
I'm suspecting this has to do with the changelog note in 2.9 Geospatial tools add support for three types of aggregations using geoshapes data: geo_bounds, geo_hash, and geo_tile.
Looking forward to your feedback on this ticket, L~