Skip to content
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

[BUG] getting incorrect result with multiple geospatial conditions in query #4739

Open
atakavci opened this issue Jun 12, 2024 · 1 comment
Assignees
Labels

Comments

@atakavci
Copy link

Describe the bug
getting no result when introduce multiple geospatial conditions
(like this one "@geofield:[DISJOINT $geospatials0] @geofield2:[INTERSECTS $geospatials1]")
into a single query where there are keys that satisfies all conditions.

To Reproduce

"FT.CREATE" "idx" "SCHEMA" "geofield" "GEOSHAPE" "FLAT" "geofield2" "GEOSHAPE" "FLAT"
"HSET" "doc1" "geofield" "POINT (10  10)" "geofield2" "POLYGON ((20 20, 25 35, 35 25, 20 20))"
"HSET" "doc2" "geofield" "POINT (50  50)" "geofield2" "POLYGON ((60 60, 65 75, 70 70, 65 55, 60 60))"
"FT.SEARCH" "idx" "@geofield:[DISJOINT $geospatials0] @geofield2:[INTERSECTS $geospatials1]" "PARAMS" "4" "geospatials0" "POLYGON ((15 15, 75 15, 50 70, 20 40, 15 15))" "geospatials1" "POLYGON ((15 15, 75 15, 50 70, 20 40, 15 15))" "DIALECT" "3"

steps above contains 5 geoshapes

    point1 = Point(10, 10);
    point2 = Point(50, 50);
    polygon1 = Polygon((20, 20), (25, 35), (35, 25), (20, 20));
    polygon2 = Polygon((60, 60), (65, 75), (70, 70), (65, 55), (60, 60));
    queryPolygon = Polygon((15, 15), (75, 15), (50, 70), (20, 40), (15, 15));

queryPolygon contains point2 and polygon1
queryPolygon disjoints point1 and polygon2

Expected behavior
I am not sure if 'AND' is in the scope of geosearch with polygons, but i expect it to return doc1 or at least fail to execute with a parsing error.

Screenshots

Environment (please complete the following information):

  • OS: [ubuntu 24.04]
  • CPU model [ i7-1270P ]
  • Version/branch [master]

Additional context
It returns when used with 'OR' | operator

"FT.SEARCH" "idx" "@geofield:[DISJOINT $geospatials0] | @geofield2:[INTERSECTS $geospatials1]" "PARAMS" "4" "geospatials0" "POLYGON ((15 15, 75 15, 50 70, 20 40, 15 15))" "geospatials1" "POLYGON ((15 15, 75 15, 50 70, 20 40, 15 15))" "DIALECT" "3"
@raz-mon
Copy link
Collaborator

raz-mon commented Jun 13, 2024

Hi @atakavci, thanks for reaching out!
I have checked and verified your findings:
No result is returned for the interserction:

127.0.0.1:6379> "FT.SEARCH" "idx" "@geofield:[DISJOINT $geospatials0] @geofield2:[INTERSECTS $geospatials1]" "PARAMS" "4" "geospatials0" "POLYGON ((15 15, 75 15, 50 70, 20 40, 15 15))" "geospatials1" "POLYGON ((15 15, 75 15, 50 70, 20 40, 15 15))" "DIALECT" "3"
1) (integer) 0

While the correct result is returned when searching for each component of the intersection:

127.0.0.1:6379> "FT.SEARCH" "idx" "@geofield:[DISJOINT $geospatials0]" "PARAMS" "4" "geospatials0" "POLYGON ((15 15, 75 15, 50 70, 20 40, 15 15))" "geospatials1" "POLYGON ((15 15, 75 15, 50 70, 20 40, 15 15))" "DIALECT" "3"
1) (integer) 1
2) "doc1"
3) 1) "geofield"
   2) "POINT (10  10)"
   3) "geofield2"
   4) "POLYGON ((20 20, 25 35, 35 25, 20 20))"
127.0.0.1:6379> "FT.SEARCH" "idx" "@geofield2:[INTERSECTS $geospatials1]" "PARAMS" "4" "geospatials0" "POLYGON ((15 15, 75 15, 50 70, 20 40, 15 15))" "geospatials1" "POLYGON ((15 15, 75 15, 50 70, 20 40, 15 15))" "DIALECT" "3"
1) (integer) 1
2) "doc1"
3) 1) "geofield"
   2) "POINT (10  10)"
   3) "geofield2"
   4) "POLYGON ((20 20, 25 35, 35 25, 20 20))"

It seems that the parsing is fine:

127.0.0.1:6379> "FT.EXPLAINCLI" "idx" "@geofield:[DISJOINT $geospatials0] @geofield2:[INTERSECTS $geospatials1]" "PARAMS" "4" "geospatials0" "POLYGON ((15 15, 75 15, 50 70, 20 40, 15 15))" "geospatials1" "POLYGON ((15 15, 75 15, 50 70, 20 40, 15 15))" "DIALECT" "3"
1) INTERSECT {
2)   GEOSHAPE{3 POLYGON ((15 15, 75 15, 50 70, 20 40, 15 15))}
3)   GEOSHAPE{4 POLYGON ((15 15, 75 15, 50 70, 20 40, 15 15))}
4) }
5) 

There indeed may be a problem here. An internal ticket was created, we will look into this and update when we have more details

@ephraimfeldblum ephraimfeldblum self-assigned this Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants