diff --git a/store/neurostore/resources/base.py b/store/neurostore/resources/base.py index b5ca5f72..76a0b076 100644 --- a/store/neurostore/resources/base.py +++ b/store/neurostore/resources/base.py @@ -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. diff --git a/store/neurostore/tests/api/test_query_params.py b/store/neurostore/tests/api/test_query_params.py index ad8f2bd5..ec022137 100644 --- a/store/neurostore/tests/api/test_query_params.py +++ b/store/neurostore/tests/api/test_query_params.py @@ -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)