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

[FIX] add func.to_tsquery #848

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion store/neurostore/resources/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ def search(self):
validate_search_query(s)
except errors.SyntaxError as e:
abort(400, description=e.args[0])
tsquery = pubmed_to_tsquery(s)
tsquery = func.to_tsquery('english', pubmed_to_tsquery(s))
q = q.filter(m._ts_vector.op("@@")(tsquery))

# Alternatively (or in addition), search on individual fields.
Expand Down
2 changes: 2 additions & 0 deletions store/neurostore/tests/api/test_query_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,11 @@ def test_multiword_queries(auth_client, ingest_neurosynth, session):

single_word_search = auth_client.get(f"/api/studies/?search={single_word}")
assert single_word_search.status_code == 200
assert len(single_word_search.json()["results"]) > 0

multi_word_search = auth_client.get(f"/api/studies/?search={multiple_words}")
assert multi_word_search.status_code == 200
assert len(multi_word_search.json()["results"]) > 0


@pytest.mark.parametrize("query, expected", valid_queries)
Expand Down
Loading