Skip to content

Commit 1f2827e

Browse files
authored
Merge pull request #132 from meilisearch/meilisearch-bump-v0.13.0
MeiliSearch Bump to v0.13.0
2 parents 3017217 + 3b359cf commit 1f2827e

10 files changed

+64
-155
lines changed

.code-samples.meilisearch.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,6 @@ update_displayed_attributes_1: |-
148148
])
149149
reset_displayed_attributes_1: |-
150150
client.get_index('movies').reset_displayed_attributes()
151-
get_accept_new_fields_1: |-
152-
client.get_index('movies').get_accept_new_fields()
153-
update_accept_new_fields_1: |-
154-
client.get_index('movies').update_accept_new_fields(False)
155151
get_index_stats_1: |-
156152
client.get_index('movies').get_stats()
157153
get_indexes_stats_1: |-
@@ -287,10 +283,6 @@ settings_guide_displayed_1: |-
287283
'rank'
288284
]
289285
})
290-
settings_guide_accept_new_fields_1: |-
291-
client.get_index('movies').update_settings({
292-
'acceptNewFields': False
293-
})
294286
documents_guide_add_movie_1: |-
295287
client.get_index('movies').add_documents([{
296288
'movie_id': '123sq178',

meilisearch/client.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -157,18 +157,6 @@ def get_keys(self):
157157
"""
158158
return self.http.get(self.config.paths.keys)
159159

160-
def get_sys_info(self):
161-
"""Get system information of MeiliSearch
162-
163-
Get information about memory usage and processor usage.
164-
165-
Returns
166-
----------
167-
sys_info: dict
168-
Information about memory and processor usage.
169-
"""
170-
return self.http.get(self.config.paths.sys_info)
171-
172160
def get_version(self):
173161
"""Get version MeiliSearch
174162

meilisearch/config.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ class Config:
66
class Paths():
77
health = "health"
88
keys = 'keys'
9-
sys_info = 'sys-info'
109
version = 'version'
1110
index = 'indexes'
1211
update = 'updates'

meilisearch/index.py

Lines changed: 5 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import json
21
import urllib
32
from datetime import datetime
43
from time import sleep
@@ -239,24 +238,18 @@ def search(self, query, opt_params=None):
239238
results: `dict`
240239
Dictionnary with hits, offset, limit, processingTime and initial query
241240
"""
242-
# Query parameters parsing
243241
if opt_params is None:
244242
opt_params = {}
245-
for key in opt_params:
246-
if key in ('facetsDistribution', 'facetFilters'):
247-
opt_params[key] = json.dumps(opt_params[key])
248-
elif isinstance(opt_params[key], list):
249-
opt_params[key] = ','.join(opt_params[key])
250-
params = {
243+
body = {
251244
'q': query,
252245
**opt_params
253246
}
254-
return self.http.get(
255-
'{}/{}/{}?{}'.format(
247+
return self.http.post(
248+
'{}/{}/{}'.format(
256249
self.config.paths.index,
257250
self.uid,
258-
self.config.paths.search,
259-
urllib.parse.urlencode(params))
251+
self.config.paths.search),
252+
body=body
260253
)
261254

262255
def get_document(self, document_id):
@@ -780,41 +773,6 @@ def reset_synonyms(self):
780773
self.__settings_url_for(self.config.paths.synonyms),
781774
)
782775

783-
# ACCEPT-NEW-FIELDS SUB-ROUTES
784-
785-
def get_accept_new_fields(self):
786-
"""
787-
Get accept-new-fields value of an index
788-
789-
Returns
790-
----------
791-
settings: `bool`
792-
Boolean containing the accept-new-fields value of the index
793-
"""
794-
return self.http.get(
795-
self.__settings_url_for(self.config.paths.accept_new_fields)
796-
)
797-
798-
def update_accept_new_fields(self, body):
799-
"""
800-
Update accept-new-fields value of an index
801-
802-
Parameters
803-
----------
804-
body: `bool`
805-
Boolean containing the accept-new-fields value
806-
807-
Returns
808-
----------
809-
update: `dict`
810-
Dictionnary containing an update id to track the action:
811-
https://docs.meilisearch.com/references/updates.html#get-an-update-status
812-
"""
813-
return self.http.post(
814-
self.__settings_url_for(self.config.paths.accept_new_fields),
815-
body
816-
)
817-
818776
# ATTRIBUTES FOR FACETING SUB-ROUTES
819777

820778
def get_attributes_for_faceting(self):

meilisearch/tests/client/test_client_sysinfo_meilisearch.py

Lines changed: 0 additions & 24 deletions
This file was deleted.

meilisearch/tests/index/test_index_search_meilisearch.py

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,28 +41,64 @@ def test_basic_search_with_empty_params(self):
4141
assert response['hits'][0]['id'] == '166428'
4242
assert '_formatted' not in response['hits'][0]
4343

44+
def test_basic_search_with_empty_query(self):
45+
"""Tests search with empty query and empty params"""
46+
response = self.index.search('')
47+
assert isinstance(response, object)
48+
assert len(response['hits']) == 0
49+
assert response['query'] == ''
50+
51+
def test_basic_search_with_placeholder(self):
52+
"""Tests search with no query [None] and empty params"""
53+
response = self.index.search(None, {})
54+
assert isinstance(response, object)
55+
assert len(response['hits']) == 20
56+
4457
def test_custom_search(self):
4558
"""Tests search with an simple query and custom parameter (attributesToHighlight)"""
4659
response = self.index.search(
4760
'Dragon',
4861
{
49-
'attributesToHighlight': 'title'
62+
'attributesToHighlight': ['title']
5063
}
5164
)
5265
assert isinstance(response, object)
5366
assert response['hits'][0]['id'] == '166428'
5467
assert '_formatted' in response['hits'][0]
5568
assert 'dragon' in response['hits'][0]['_formatted']['title'].lower()
5669

70+
def test_custom_search_with_empty_query(self):
71+
"""Tests search with empty query and custom parameter (attributesToHighlight)"""
72+
response = self.index.search(
73+
'',
74+
{
75+
'attributesToHighlight': ['title']
76+
}
77+
)
78+
assert isinstance(response, object)
79+
assert len(response['hits']) == 0
80+
assert response['query'] == ''
81+
82+
def test_custom_search_with_placeholder(self):
83+
"""Tests search with no query [None] and custom parameter (limit)"""
84+
response = self.index.search(
85+
None,
86+
{
87+
'limit': 5
88+
}
89+
)
90+
assert isinstance(response, object)
91+
assert len(response['hits']) == 5
92+
5793
def test_custom_search_params_with_wildcard(self):
5894
"""Tests search with '*' in query params"""
5995
response = self.index.search(
6096
'a',
6197
{
6298
'limit': 5,
63-
'attributesToHighlight': '*',
64-
'attributesToRetrieve': '*',
65-
'attributesToCrop': '*',
99+
'attributesToHighlight': ['*'],
100+
'attributesToRetrieve': ['*'],
101+
'attributesToCrop': ['*'],
66102
}
67103
)
68104
assert isinstance(response, object)
@@ -76,9 +112,9 @@ def test_custom_search_params_with_simple_string(self):
76112
'a',
77113
{
78114
'limit': 5,
79-
'attributesToHighlight': 'title',
80-
'attributesToRetrieve': 'title',
81-
'attributesToCrop': 'title',
115+
'attributesToHighlight': ['title'],
116+
'attributesToRetrieve': ['title'],
117+
'attributesToCrop': ['title'],
82118
}
83119
)
84120
assert isinstance(response, object)

meilisearch/tests/settings/test_settings.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,10 @@ def test_get_settings_default(self):
3333
for rule in self.default_ranking_rules:
3434
assert rule in response['rankingRules']
3535
assert response['distinctAttribute'] is None
36-
assert response['searchableAttributes'] == []
37-
assert response['displayedAttributes'] == []
36+
assert response['searchableAttributes'] == ['*']
37+
assert response['displayedAttributes'] == ['*']
3838
assert response['stopWords'] == []
3939
assert response['synonyms'] == {}
40-
assert response['acceptNewFields'] is True
4140

4241
def test_update_settings(self):
4342
"""Tests updating some settings"""
@@ -52,10 +51,9 @@ def test_update_settings(self):
5251
assert response['distinctAttribute'] is None
5352
for attribute in self.new_settings['searchableAttributes']:
5453
assert attribute in response['searchableAttributes']
55-
assert response['displayedAttributes'] == []
54+
assert response['displayedAttributes'] == ['*']
5655
assert response['stopWords'] == []
5756
assert response['synonyms'] == {}
58-
assert response['acceptNewFields'] is True
5957

6058
def test_reset_settings(self):
6159
"""Tests resetting default settings"""
@@ -68,9 +66,7 @@ def test_reset_settings(self):
6866
for rule in self.default_ranking_rules:
6967
assert rule in response['rankingRules']
7068
assert response['distinctAttribute'] is None
71-
for attribute in self.new_settings['searchableAttributes']:
72-
assert attribute in response['searchableAttributes']
73-
assert attribute in response['displayedAttributes']
69+
assert response['displayedAttributes'] == ['*']
70+
assert response['searchableAttributes'] == ['*']
7471
assert response['stopWords'] == []
7572
assert response['synonyms'] == {}
76-
assert response['acceptNewFields'] is True

meilisearch/tests/settings/test_settings_accept_new_fields_meilisearch.py

Lines changed: 0 additions & 32 deletions
This file was deleted.

meilisearch/tests/settings/test_settings_displayed_attributes_meilisearch.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,20 @@ def test_get_displayed_attributes(self):
2525
""" Tests getting the displayed attributes before and after indexing a dataset """
2626
response = self.index.get_displayed_attributes()
2727
assert isinstance(response, object)
28-
assert response == []
28+
assert response == ['*']
2929
response = self.index.add_documents(self.dataset_json, primary_key='id')
3030
self.index.wait_for_pending_update(response['updateId'])
3131
get_attributes = self.index.get_displayed_attributes()
32-
for attribute in self.displayed_attributes:
33-
assert attribute in get_attributes
32+
assert get_attributes == ['*']
3433

3534
def test_update_displayed_attributes(self):
3635
"""Tests updating the displayed attributes"""
37-
get_attributes = self.index.get_displayed_attributes()
38-
response = self.index.update_displayed_attributes(get_attributes[1:])
36+
response = self.index.update_displayed_attributes(self.displayed_attributes)
3937
self.index.wait_for_pending_update(response['updateId'])
4038
get_attributes_new = self.index.get_displayed_attributes()
41-
assert len(get_attributes_new) == len(self.displayed_attributes) - 1
42-
assert get_attributes[0] not in get_attributes_new
39+
assert len(get_attributes_new) == len(self.displayed_attributes)
40+
for attribute in self.displayed_attributes:
41+
assert attribute in get_attributes_new
4342

4443
def test_reset_displayed_attributes(self):
4544
"""Tests the reset of displayedAttributes to default values (in dataset)"""
@@ -48,6 +47,4 @@ def test_reset_displayed_attributes(self):
4847
assert 'updateId' in response
4948
self.index.wait_for_pending_update(response['updateId'])
5049
get_attributes = self.index.get_displayed_attributes()
51-
assert len(get_attributes) == len(self.displayed_attributes)
52-
for attribute in self.displayed_attributes:
53-
assert attribute in get_attributes
50+
assert get_attributes == ['*']

meilisearch/tests/settings/test_settings_searchable_attributes_meilisearch.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,11 @@ def test_get_searchable_attributes(self):
2626
"""Tests getting the searchable attributes on an empty and populated index"""
2727
response = self.index.get_searchable_attributes()
2828
assert isinstance(response, object)
29-
assert response == []
29+
assert response == ['*']
3030
response = self.index.add_documents(self.dataset_json, primary_key='id')
3131
self.index.wait_for_pending_update(response['updateId'])
3232
get_attributes = self.index.get_searchable_attributes()
33-
for attribute in self.full_searchable_attributes:
34-
assert attribute in get_attributes
33+
assert get_attributes == ['*']
3534

3635

3736
def test_update_searchable_attributes(self):
@@ -41,6 +40,7 @@ def test_update_searchable_attributes(self):
4140
assert 'updateId' in response
4241
self.index.wait_for_pending_update(response['updateId'])
4342
response = self.index.get_searchable_attributes()
43+
assert len(response) == len(self.new_searchable_attributes)
4444
for attribute in self.new_searchable_attributes:
4545
assert attribute in response
4646

@@ -51,5 +51,4 @@ def test_reset_searchable_attributes(self):
5151
assert 'updateId' in response
5252
self.index.wait_for_pending_update(response['updateId'])
5353
response = self.index.get_searchable_attributes()
54-
for attribute in self.full_searchable_attributes:
55-
assert attribute in response
54+
assert response == ['*']

0 commit comments

Comments
 (0)