Skip to content

Commit 7fef228

Browse files
committed
Rename attributes_for_faceting into filterable_attributes
1 parent 2d8db6f commit 7fef228

File tree

4 files changed

+33
-32
lines changed

4 files changed

+33
-32
lines changed

meilisearch/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Paths():
2323
stop_words = 'stop-words'
2424
synonyms = 'synonyms'
2525
accept_new_fields = 'accept-new-fields'
26-
attributes_for_faceting = 'attributes-for-faceting'
26+
filterable_attributes = 'filterable-attributes'
2727
dumps = 'dumps'
2828

2929
def __init__(

meilisearch/index.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,8 @@ def wait_for_pending_update(
215215
while elapsed_time < timeout_in_ms:
216216
get_update = self.get_update_status(update_id)
217217

218-
if get_update['status'] != 'enqueued':
218+
print(get_update['status'])
219+
if get_update['status'] != 'enqueued' and get_update['status'] != 'processing':
219220
return get_update
220221
sleep(interval_in_ms / 1000)
221222
time_delta = datetime.now() - start_time
@@ -975,7 +976,7 @@ def reset_synonyms(self) -> Dict[str, int]:
975976

976977
# ATTRIBUTES FOR FACETING SUB-ROUTES
977978

978-
def get_attributes_for_faceting(self) -> List[str]:
979+
def get_filterable_attributes(self) -> List[str]:
979980
"""
980981
Get attributes for faceting of the index.
981982
@@ -990,10 +991,10 @@ def get_attributes_for_faceting(self) -> List[str]:
990991
An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors
991992
"""
992993
return self.http.get(
993-
self.__settings_url_for(self.config.paths.attributes_for_faceting)
994+
self.__settings_url_for(self.config.paths.filterable_attributes)
994995
)
995996

996-
def update_attributes_for_faceting(self, body: List[str]) -> Dict[str, int]:
997+
def update_filterable_attributes(self, body: List[str]) -> Dict[str, int]:
997998
"""
998999
Update attributes for faceting of the index.
9991000
@@ -1014,11 +1015,11 @@ def update_attributes_for_faceting(self, body: List[str]) -> Dict[str, int]:
10141015
An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors
10151016
"""
10161017
return self.http.post(
1017-
self.__settings_url_for(self.config.paths.attributes_for_faceting),
1018+
self.__settings_url_for(self.config.paths.filterable_attributes),
10181019
body
10191020
)
10201021

1021-
def reset_attributes_for_faceting(self) -> Dict[str, int]:
1022+
def reset_filterable_attributes(self) -> Dict[str, int]:
10221023
"""Reset attributes for faceting of the index to default values.
10231024
10241025
Returns
@@ -1033,7 +1034,7 @@ def reset_attributes_for_faceting(self) -> Dict[str, int]:
10331034
An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors
10341035
"""
10351036
return self.http.delete(
1036-
self.__settings_url_for(self.config.paths.attributes_for_faceting),
1037+
self.__settings_url_for(self.config.paths.filterable_attributes),
10371038
)
10381039

10391040
@staticmethod

meilisearch/tests/index/test_index_search_meilisearch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def test_custom_search_params_with_string_list(index_with_documents):
115115

116116
def test_custom_search_params_with_facets_distribution(index_with_documents):
117117
index = index_with_documents()
118-
update = index.update_attributes_for_faceting(['genre'])
118+
update = index.update_filterable_attributes(['genre'])
119119
index.wait_for_pending_update(update['updateId'])
120120
response = index.search(
121121
'world',
Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,59 @@
11
# pylint: disable=invalid-name
22

3-
ATTRIBUTES_FOR_FACETING = ['title', 'release_date']
3+
FILTERABLE_ATTRIBUTES = ['title', 'release_date']
44

5-
def test_get_attributes_for_faceting(empty_index):
5+
def test_get_filterable_attributes(empty_index):
66
"""Tests getting the attributes for faceting."""
7-
response = empty_index().get_attributes_for_faceting()
7+
response = empty_index().get_filterable_attributes()
88
assert isinstance(response, list)
99
assert response == []
1010

11-
def test_update_attributes_for_faceting(empty_index):
11+
def test_update_filterable_attributes(empty_index):
1212
"""Tests updating the attributes for faceting."""
1313
index = empty_index()
14-
response = index.update_attributes_for_faceting(ATTRIBUTES_FOR_FACETING)
14+
response = index.update_filterable_attributes(FILTERABLE_ATTRIBUTES)
1515
index.wait_for_pending_update(response['updateId'])
16-
get_attributes_new = index.get_attributes_for_faceting()
17-
assert len(get_attributes_new) == len(ATTRIBUTES_FOR_FACETING)
18-
get_attributes = index.get_attributes_for_faceting()
19-
for attribute in ATTRIBUTES_FOR_FACETING:
16+
get_attributes_new = index.get_filterable_attributes()
17+
assert len(get_attributes_new) == len(FILTERABLE_ATTRIBUTES)
18+
get_attributes = index.get_filterable_attributes()
19+
for attribute in FILTERABLE_ATTRIBUTES:
2020
assert attribute in get_attributes
2121

22-
def test_update_attributes_for_faceting_to_none(empty_index):
22+
def test_update_filterable_attributes_to_none(empty_index):
2323
"""Tests updating the attributes for faceting at null."""
2424
index = empty_index()
2525
# Update the settings first
26-
response = index.update_attributes_for_faceting(ATTRIBUTES_FOR_FACETING)
26+
response = index.update_filterable_attributes(FILTERABLE_ATTRIBUTES)
2727
update = index.wait_for_pending_update(response['updateId'])
2828
assert update['status'] == 'processed'
2929
# Check the settings have been correctly updated
30-
get_attributes = index.get_attributes_for_faceting()
31-
for attribute in ATTRIBUTES_FOR_FACETING:
30+
get_attributes = index.get_filterable_attributes()
31+
for attribute in FILTERABLE_ATTRIBUTES:
3232
assert attribute in get_attributes
3333
# Launch test to update at null the setting
34-
response = index.update_attributes_for_faceting(None)
34+
response = index.update_filterable_attributes(None)
3535
index.wait_for_pending_update(response['updateId'])
36-
response = index.get_attributes_for_faceting()
36+
response = index.get_filterable_attributes()
3737
assert response == []
3838

39-
def test_reset_attributes_for_faceting(empty_index):
39+
def test_reset_filterable_attributes(empty_index):
4040
"""Tests resetting the attributes for faceting setting to its default value"""
4141
index = empty_index()
4242
# Update the settings first
43-
response = index.update_attributes_for_faceting(ATTRIBUTES_FOR_FACETING)
43+
response = index.update_filterable_attributes(FILTERABLE_ATTRIBUTES)
4444
update = index.wait_for_pending_update(response['updateId'])
4545
assert update['status'] == 'processed'
4646
# Check the settings have been correctly updated
47-
get_attributes_new = index.get_attributes_for_faceting()
48-
assert len(get_attributes_new) == len(ATTRIBUTES_FOR_FACETING)
49-
get_attributes = index.get_attributes_for_faceting()
50-
for attribute in ATTRIBUTES_FOR_FACETING:
47+
get_attributes_new = index.get_filterable_attributes()
48+
assert len(get_attributes_new) == len(FILTERABLE_ATTRIBUTES)
49+
get_attributes = index.get_filterable_attributes()
50+
for attribute in FILTERABLE_ATTRIBUTES:
5151
assert attribute in get_attributes
5252
# Check the reset of the settings
53-
response = index.reset_attributes_for_faceting()
53+
response = index.reset_filterable_attributes()
5454
assert isinstance(response, dict)
5555
assert 'updateId' in response
5656
index.wait_for_pending_update(response['updateId'])
57-
response = index.get_attributes_for_faceting()
57+
response = index.get_filterable_attributes()
5858
assert isinstance(response, list)
5959
assert response == []

0 commit comments

Comments
 (0)