Skip to content

Commit 73559b8

Browse files
committed
Fix bug: Search params are not applied when they are a list of strings
1 parent a816019 commit 73559b8

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

meilisearch/index.py

+3
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,9 @@ def search(self, query, opt_params=None):
246246
if opt_params is None:
247247
opt_params = {}
248248
search_param = {'q': query}
249+
for key in opt_params:
250+
if isinstance(opt_params[key], list):
251+
opt_params[key] = ",".join(opt_params[key])
249252
params = {**search_param, **opt_params}
250253
return self.http.get(
251254
'{}/{}/{}?{}'.format(

meilisearch/tests/index/test_index_search_meilisearch.py

+17-2
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,20 @@ def test_basic_search_params_with_simple_string(self):
8686
assert "title" in response['hits'][0]['_formatted']
8787
assert not "release_date" in response['hits'][0]['_formatted']
8888

89-
# Add def test_basic_search_params_with_string_list(self):
90-
# when bug (issue #85) is fixed
89+
def test_basic_search_params_with_string_list(self):
90+
"""Tests search with string list in query params"""
91+
response = self.index.search(
92+
'a',
93+
{
94+
'limit': 5,
95+
'attributesToRetrieve': ['title', 'overview'],
96+
"attributesToHighlight": ["title"],
97+
}
98+
)
99+
assert isinstance(response, object)
100+
assert len(response['hits']) == 5
101+
assert "title" in response['hits'][0]
102+
assert "overview" in response['hits'][0]
103+
assert not "release_date" in response['hits'][0]
104+
assert "title" in response['hits'][0]['_formatted']
105+
assert not "overview" in response['hits'][0]['_formatted']

0 commit comments

Comments
 (0)