Skip to content

Commit

Permalink
Fixed query to match exact-match syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
vladvildanov committed Jan 27, 2025
1 parent 76da272 commit 52499b6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
7 changes: 3 additions & 4 deletions tests/test_asyncio/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,12 +683,11 @@ async def test_explaincli(decoded_r: redis.Redis):


@pytest.mark.redismod
@skip_if_server_version_gte("7.9.0")
async def test_summarize(decoded_r: redis.Redis):
await createIndex(decoded_r.ft())
await waitForIndex(decoded_r, "idx")

q = Query("king henry").paging(0, 1)
q = Query("\"king henry\"").paging(0, 1)
q.highlight(fields=("play", "txt"), tags=("<b>", "</b>"))
q.summarize("txt")

Expand All @@ -700,7 +699,7 @@ async def test_summarize(decoded_r: redis.Redis):
== doc.txt
)

q = Query("king henry").paging(0, 1).summarize().highlight()
q = Query("\"king henry\"").paging(0, 1).summarize().highlight()

doc = sorted((await decoded_r.ft().search(q)).docs)[0]
assert "<b>Henry</b> ... " == doc.play
Expand All @@ -716,7 +715,7 @@ async def test_summarize(decoded_r: redis.Redis):
== doc["extra_attributes"]["txt"]
)

q = Query("king henry").paging(0, 1).summarize().highlight()
q = Query("\"king henry\"").paging(0, 1).summarize().highlight()

doc = sorted((await decoded_r.ft().search(q))["results"])[0]
assert "<b>Henry</b> ... " == doc["extra_attributes"]["play"]
Expand Down
8 changes: 4 additions & 4 deletions tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,24 +643,24 @@ def test_explaincli(client):


@pytest.mark.redismod
@skip_if_server_version_gte("7.9.0")
def test_summarize(client):
createIndex(client.ft())
waitForIndex(client, getattr(client.ft(), "index_name", "idx"))

q = Query("king henry").paging(0, 1)
q = Query("\"king henry\"").paging(0, 1)
q.highlight(fields=("play", "txt"), tags=("<b>", "</b>"))
q.summarize("txt")

if is_resp2_connection(client):
print(client.ft().search(q).docs)
doc = sorted(client.ft().search(q).docs)[0]
assert "<b>Henry</b> IV" == doc.play
assert (
"ACT I SCENE I. London. The palace. Enter <b>KING</b> <b>HENRY</b>, LORD JOHN OF LANCASTER, the EARL of WESTMORELAND, SIR... " # noqa
== doc.txt
)

q = Query("king henry").paging(0, 1).summarize().highlight()
q = Query("\"king henry\"").paging(0, 1).summarize().highlight()

doc = sorted(client.ft().search(q).docs)[0]
assert "<b>Henry</b> ... " == doc.play
Expand All @@ -676,7 +676,7 @@ def test_summarize(client):
== doc["extra_attributes"]["txt"]
)

q = Query("king henry").paging(0, 1).summarize().highlight()
q = Query("\"king henry\"").paging(0, 1).summarize().highlight()

doc = sorted(client.ft().search(q)["results"])[0]
assert "<b>Henry</b> ... " == doc["extra_attributes"]["play"]
Expand Down

0 comments on commit 52499b6

Please sign in to comment.