New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GIS Query not working on ES as expected #9079
Comments
The test case i have is a basic unit test case for the feature. To me it is not a corner case (may be i am mistaken). If anyone can recommend a workaround, that would help as well. |
Hey @andyboagra I figured out what was going on, I actually had this issue a while back and it took some time for me to remember what the deal was. The co-ordinates you specified for the You should be using: "coordinates": [
["-118.68", "35.32"],
["-118.58", "35.30"]
] ... instead of "coordinates": [
["-118.58", "35.32"],
["-118.68", "35.30"]
] It's actually quite annoying that you don't get a warning, as changing the I'm assuming that the envelope you created wraps all the way around the world and excludes only the small section you were trying to target, although I didn't spend the time investigating more. Hope that helps, I'll try to write up a minimal testcase regarding the bbox validation and open a separate ticket. If you can confirm this works this issue can probably be closed. |
Works as expected based on Peter's suggestion. |
ShapeBuilder expected coordinates for Envelope types in strict Top-Left, Bottom-Right order. Given that GeoJSON does not enforce coordinate order (as seen in elastic#8672) clients could specify envelope bounds in any order and be compliant with the GeoJSON spec but not the ES ShapeBuilder logic. This change loosens the ShapeBuilder requirements on envelope coordinate order, reordering where necessary. closes elastic#2544 closes elastic#9067 closes elastic#9079 closes elastic#9080
ShapeBuilder expected coordinates for Envelope types in strict Top-Left, Bottom-Right order. Given that GeoJSON does not enforce coordinate order (as seen in #8672) clients could specify envelope bounds in any order and be compliant with the GeoJSON spec but not the ES ShapeBuilder logic. This change loosens the ShapeBuilder requirements on envelope coordinate order, reordering where necessary. closes #2544 closes #9067 closes #9079 closes #9080
ShapeBuilder expected coordinates for Envelope types in strict Top-Left, Bottom-Right order. Given that GeoJSON does not enforce coordinate order (as seen in #8672) clients could specify envelope bounds in any order and be compliant with the GeoJSON spec but not the ES ShapeBuilder logic. This change loosens the ShapeBuilder requirements on envelope coordinate order, reordering where necessary. closes #2544 closes #9067 closes #9079 closes #9080
@andyboagra Great to hear you got it working! A patch has been pushed to self correct coordinate order on envelope shape type. Many thanks to both you and @missinglink for identifying this issue. Cheers! |
ShapeBuilder expected coordinates for Envelope types in strict Top-Left, Bottom-Right order. Given that GeoJSON does not enforce coordinate order (as seen in elastic#8672) clients could specify envelope bounds in any order and be compliant with the GeoJSON spec but not the ES ShapeBuilder logic. This change loosens the ShapeBuilder requirements on envelope coordinate order, reordering where necessary. closes elastic#2544 closes elastic#9067 closes elastic#9079 closes elastic#9080
Issue raised:
Below is my request/ response. I am puzzled why do i get a polygon returned when it does not intersect w/ envelope defined in request. What am i missing? Appreciate quick response. Thanks,
Andy
Request:
_search
{"size": 51000,"query": { "geo_shape": { "POLYS": {"shape": {"type": "envelope", "coordinates": [[-118.58, 35.32],[-118.68, 35.30]]}, "relation": "intersects"}}}}
Response:
"took" : 1172,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 94420,
"max_score" : 1.0,
"hits" : [ {
"_index" : "XXX",
"_type" : "XXX_data",
"_id" : "1234",
"_score" : 1.0,
"_source":{"POLYS":{"type":"Polygon","coordinates":[[[-117.7656797176,35.2420721325],[-117.766565557,35.2429646794],[-117.7675000712,35.2429532681],[-117.7661768866,35.2415486409],[-117.7661640858,35.2415341862],[-117.765523769,35.2419167046],[-117.7656797176,35.2420721325]]]}, "STATE": "XX", "ID": 1234 ,"COUNTY_NAME": "YY"}]}
}, {
"_index" : "XXX",
"_type" : "XXX_data",
"_id" : "1235",
"_score" : 1.0,
....
....
_mapping?pretty'
{
"XXX" : {
"mappings" : {
"XXX_data" : {
"properties" : {
"COUNTY_NAME" : {
"type" : "string"
},
"ID" : {
"type" : "long"
},
"POLYS" : {
"type" : "geo_shape",
"tree" : "quadtree",
"tree_levels" : 26
},
"STATE" : {
"type" : "string"
}
}
}
}
}
}
Reply from Peter Johnson:
I tried to fix this but you're right, it seems to be a bug. I've attached a full bug report which you might want to add to a new github issue.
https://gist.github.com/anonymous/c250d602d1e7fe6d3655
https://gist.github.com/missinglink/6e96f06e9e6032aa6416
I also tried using 'geohash' instead of 'quadtree' with the same result.
-P
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/f1c49b57-721d-4abd-bb1d-ac54631e543a%40googlegroups.com.
The text was updated successfully, but these errors were encountered: