Skip to content

Commit 0d14126

Browse files
eskombrocurquiza
authored andcommitted
Update settings behavior (#138)
Remove acceptNewFields routes Update tests for settings
1 parent 2273d2a commit 0d14126

6 files changed

+16
-98
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/index.py

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -773,41 +773,6 @@ def reset_synonyms(self):
773773
self.__settings_url_for(self.config.paths.synonyms),
774774
)
775775

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

813778
def get_attributes_for_faceting(self):

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 & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,21 @@ 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"""
3736
get_attributes = self.index.get_displayed_attributes()
38-
response = self.index.update_displayed_attributes(get_attributes[1:])
37+
response = self.index.update_displayed_attributes(self.displayed_attributes)
3938
self.index.wait_for_pending_update(response['updateId'])
4039
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
40+
assert len(get_attributes_new) == len(self.displayed_attributes)
41+
for attribute in self.displayed_attributes:
42+
assert attribute in get_attributes_new
4343

4444
def test_reset_displayed_attributes(self):
4545
"""Tests the reset of displayedAttributes to default values (in dataset)"""
@@ -48,6 +48,4 @@ def test_reset_displayed_attributes(self):
4848
assert 'updateId' in response
4949
self.index.wait_for_pending_update(response['updateId'])
5050
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
51+
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)