Skip to content

Commit

Permalink
Fix oddity with plainto_tsquery vs to_tsquery
Browse files Browse the repository at this point in the history
  • Loading branch information
danielballan committed Jan 26, 2024
1 parent 8634e31 commit 810f6b2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions tiled/_tests/test_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
mapping["does_not_contain_z"] = ArrayAdapter.from_array(
numpy.ones(10), metadata={"letters": list(string.ascii_lowercase[:-1])}
)
mapping["full_text_test_case"] = ArrayAdapter.from_array(
numpy.ones(10), metadata={"color": "purple"}
)

mapping["specs_foo_bar"] = ArrayAdapter.from_array(numpy.ones(10), specs=["foo", "bar"])
mapping["specs_foo_bar_baz"] = ArrayAdapter.from_array(
Expand Down Expand Up @@ -168,6 +171,9 @@ def cm():
cm = nullcontext
with cm():
assert list(client.search(FullText("z"))) == ["z", "does_contain_z"]
# plainto_tsquery fails to find certain words, weirdly, so it is a useful
# test that we are using tsquery
assert list(client.search(FullText("purple"))) == ["full_text_test_case"]


def test_regex(client):
Expand Down
2 changes: 1 addition & 1 deletion tiled/catalog/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ def full_text(query, tree):
tsvector = func.jsonb_to_tsvector(
cast("simple", REGCONFIG), orm.Node.metadata_, cast(["string"], JSONB)
)
condition = tsvector.op("@@")(func.to_tsquery(query.text))
condition = tsvector.op("@@")(func.to_tsquery("simple", query.text))
# condition = tsvector.match(query.text)
else:
raise UnsupportedQueryType("full_text")
Expand Down

0 comments on commit 810f6b2

Please sign in to comment.