Skip to content

Commit

Permalink
add func.to_tsquery
Browse files Browse the repository at this point in the history
  • Loading branch information
jdkent committed Nov 12, 2024
1 parent ea5cdc4 commit 89742be
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
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

0 comments on commit 89742be

Please sign in to comment.