|
13 | 13 | from redis.commands.search import Search
|
14 | 14 | from redis.commands.search.field import (
|
15 | 15 | GeoField,
|
| 16 | + GeoShapeField, |
16 | 17 | NumericField,
|
17 | 18 | TagField,
|
18 | 19 | TextField,
|
@@ -2266,3 +2267,20 @@ def test_query_timeout(r: redis.Redis):
|
2266 | 2267 | q2 = Query("foo").timeout("not_a_number")
|
2267 | 2268 | with pytest.raises(redis.ResponseError):
|
2268 | 2269 | r.ft().search(q2)
|
| 2270 | + |
| 2271 | + |
| 2272 | +@pytest.mark.redismod |
| 2273 | +def test_geoshape(client: redis.Redis): |
| 2274 | + client.ft().create_index((GeoShapeField("geom", GeoShapeField.FLAT))) |
| 2275 | + waitForIndex(client, getattr(client.ft(), "index_name", "idx")) |
| 2276 | + client.hset("small", "geom", "POLYGON((1 1, 1 100, 100 100, 100 1, 1 1))") |
| 2277 | + client.hset("large", "geom", "POLYGON((1 1, 1 200, 200 200, 200 1, 1 1))") |
| 2278 | + q1 = Query("@geom:[WITHIN $poly]").dialect(3) |
| 2279 | + qp1 = {"poly": "POLYGON((0 0, 0 150, 150 150, 150 0, 0 0))"} |
| 2280 | + q2 = Query("@geom:[CONTAINS $poly]").dialect(3) |
| 2281 | + qp2 = {"poly": "POLYGON((2 2, 2 50, 50 50, 50 2, 2 2))"} |
| 2282 | + result = client.ft().search(q1, query_params=qp1) |
| 2283 | + assert len(result.docs) == 1 |
| 2284 | + assert result.docs[0]["id"] == "small" |
| 2285 | + result = client.ft().search(q2, query_params=qp2) |
| 2286 | + assert len(result.docs) == 2 |
0 commit comments