summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authordvora-h <67596500+dvora-h@users.noreply.github.com>2022-08-04 16:46:28 +0300
committerGitHub <noreply@github.com>2022-08-04 16:46:28 +0300
commit2cea637b2e936265d2001043d2b2d4e62559dc17 (patch)
tree99e4614780f5ae5694675692ab66c0b9f6d1e85b /tests
parent34f07a716f1029a38cc000177c931a7ea8bd712e (diff)
downloadredis-py-4.4.0rc1.tar.gz
Add support for WITHSUFFIXTRIE to FT.CREATE (#2324)v4.4.0rc1
* withsuffixtrie * Update test_search.py * fix
Diffstat (limited to 'tests')
-rw-r--r--tests/test_asyncio/test_search.py24
-rw-r--r--tests/test_search.py24
2 files changed, 48 insertions, 0 deletions
diff --git a/tests/test_asyncio/test_search.py b/tests/test_asyncio/test_search.py
index 4824e49..862c21b 100644
--- a/tests/test_asyncio/test_search.py
+++ b/tests/test_asyncio/test_search.py
@@ -1046,6 +1046,30 @@ async def test_aggregations_sort_by_and_limit(modclient: redis.Redis):
@pytest.mark.redismod
+@pytest.mark.experimental
+async def test_withsuffixtrie(modclient: redis.Redis):
+ # create index
+ assert await modclient.ft().create_index((TextField("txt"),))
+ await waitForIndex(modclient, getattr(modclient.ft(), "index_name", "idx"))
+ info = await modclient.ft().info()
+ assert "WITHSUFFIXTRIE" not in info["attributes"][0]
+ assert await modclient.ft().dropindex("idx")
+
+ # create withsuffixtrie index (text field)
+ assert await modclient.ft().create_index((TextField("t", withsuffixtrie=True)))
+ await waitForIndex(modclient, getattr(modclient.ft(), "index_name", "idx"))
+ info = await modclient.ft().info()
+ assert "WITHSUFFIXTRIE" in info["attributes"][0]
+ assert await modclient.ft().dropindex("idx")
+
+ # create withsuffixtrie index (tag field)
+ assert await modclient.ft().create_index((TagField("t", withsuffixtrie=True)))
+ await waitForIndex(modclient, getattr(modclient.ft(), "index_name", "idx"))
+ info = await modclient.ft().info()
+ assert "WITHSUFFIXTRIE" in info["attributes"][0]
+
+
+@pytest.mark.redismod
@skip_if_redis_enterprise()
async def test_search_commands_in_pipeline(modclient: redis.Redis):
p = await modclient.ft().pipeline()
diff --git a/tests/test_search.py b/tests/test_search.py
index ee4fa55..5fe5ab1 100644
--- a/tests/test_search.py
+++ b/tests/test_search.py
@@ -1712,3 +1712,27 @@ def test_expire_while_search(modclient: redis.Redis):
modclient.ft().search(Query("*")).docs[1]
time.sleep(1)
assert 2 == modclient.ft().search(Query("*")).total
+
+
+@pytest.mark.redismod
+@pytest.mark.experimental
+def test_withsuffixtrie(modclient: redis.Redis):
+ # create index
+ assert modclient.ft().create_index((TextField("txt"),))
+ waitForIndex(modclient, getattr(modclient.ft(), "index_name", "idx"))
+ info = modclient.ft().info()
+ assert "WITHSUFFIXTRIE" not in info["attributes"][0]
+ assert modclient.ft().dropindex("idx")
+
+ # create withsuffixtrie index (text fiels)
+ assert modclient.ft().create_index((TextField("t", withsuffixtrie=True)))
+ waitForIndex(modclient, getattr(modclient.ft(), "index_name", "idx"))
+ info = modclient.ft().info()
+ assert "WITHSUFFIXTRIE" in info["attributes"][0]
+ assert modclient.ft().dropindex("idx")
+
+ # create withsuffixtrie index (tag field)
+ assert modclient.ft().create_index((TagField("t", withsuffixtrie=True)))
+ waitForIndex(modclient, getattr(modclient.ft(), "index_name", "idx"))
+ info = modclient.ft().info()
+ assert "WITHSUFFIXTRIE" in info["attributes"][0]