Skip to content

Changes related to the next MeiliSearch release (v0.21.0) #250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 39 commits into from
Aug 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
59762f2
Update README.md
meili-bot Apr 27, 2021
c8051c6
Merge branch 'main' into bump-meilisearch-v0.21.0
curquiza Jun 21, 2021
064e771
Merge branch 'main' into bump-meilisearch-v0.21.0
curquiza Jul 1, 2021
569395e
Merge branch 'main' into bump-meilisearch-v0.21.0
alallema Jul 19, 2021
d403bd1
Update README
alallema Jul 19, 2021
2d8db6f
Merge pull request #286 from meilisearch/readme
alallema Jul 19, 2021
7fef228
Rename attributes_for_faceting into filterable_attributes
alallema Jul 19, 2021
4d90b73
FIx print typo
alallema Jul 19, 2021
07bc4e1
Merge pull request #287 from meilisearch/filterable-attributes
alallema Jul 19, 2021
92a283e
Update wait_for_pending_update status
alallema Jul 19, 2021
96b8f2d
Merge pull request #288 from meilisearch/improve-wfpu
alallema Jul 19, 2021
839c4ca
Fix a part of the tests
alallema Jul 20, 2021
124effd
Clean facetFilters tests
alallema Jul 20, 2021
71a022e
Merge pull request #289 from meilisearch/fix-tests
alallema Jul 20, 2021
b4660e3
Add somes tests
alallema Jul 20, 2021
61c4697
Merge pull request #290 from meilisearch/add-tests
alallema Jul 20, 2021
249523e
Update code sample
alallema Jul 20, 2021
405fe2c
Merge pull request #291 from meilisearch/code-sample
alallema Jul 20, 2021
8067080
Change file name
alallema Jul 20, 2021
0ba8cd5
Merge pull request #292 from meilisearch/filterable-attributes
alallema Jul 20, 2021
5f77a60
Fix code-samples
alallema Jul 20, 2021
3f033ee
Merge pull request #293 from meilisearch/code-sample
alallema Jul 20, 2021
c50f2b5
Fix code sample
alallema Jul 21, 2021
eae85c3
Merge pull request #295 from meilisearch/code-sample
alallema Jul 21, 2021
9571ce3
Merge branch 'main' into bump-meilisearch-v0.21.0
alallema Aug 4, 2021
ea0b2ab
Merge branch 'main' into bump-meilisearch-v0.21.0
alallema Aug 10, 2021
1b0ba70
Merge branch 'main' into bump-meilisearch-v0.21.0
alallema Aug 17, 2021
454790c
Merge branch 'main' into bump-meilisearch-v0.21.0
alallema Aug 20, 2021
f2e4153
Update meilisearch/tests/settings/test_settings_filterable_attributes…
alallema Aug 24, 2021
78a8284
Update meilisearch/tests/settings/test_settings_filterable_attributes…
alallema Aug 24, 2021
7aaed48
Update meilisearch/tests/settings/test_settings_filterable_attributes…
alallema Aug 24, 2021
f9e2a84
Update meilisearch/index.py
alallema Aug 24, 2021
efe44f9
Update meilisearch/index.py
alallema Aug 24, 2021
164fe3f
Update meilisearch/index.py
alallema Aug 24, 2021
518311e
Update meilisearch/index.py
alallema Aug 24, 2021
d15f903
Update meilisearch/tests/settings/test_settings_filterable_attributes…
alallema Aug 24, 2021
15f90db
Fix forgotten attribute for faceting
alallema Aug 24, 2021
1ff96d2
Merge pull request #313 from meilisearch/fix-filterable-attribute
alallema Aug 24, 2021
4c9e809
Merge branch 'main' into bump-meilisearch-v0.21.0
alallema Aug 24, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 42 additions & 46 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,10 @@ get_settings_1: |-
update_settings_1: |-
client.index('movies').update_settings({
'rankingRules': [
'typo',
'words',
'typo',
'proximity',
'attribute',
'wordsPosition',
'exactness',
'desc(release_date)',
'desc(rank)'
Expand Down Expand Up @@ -104,11 +103,10 @@ get_ranking_rules_1: |-
client.index('movies').get_ranking_rules()
update_ranking_rules_1: |-
client.index('movies').update_ranking_rules([
'typo',
'words',
'typo',
'proximity',
'attribute',
'wordsPosition',
'exactness',
'asc(release_date)',
'desc(rank)'
Expand All @@ -121,6 +119,15 @@ update_distinct_attribute_1: |-
client.index('movies').update_distinct_attribute('movie_id')
reset_distinct_attribute_1: |-
client.index('movies').reset_distinct_attribute()
get_filterable_attributes_1: |-
client.index('movies').get_filterable_attributes()
update_filterable_attributes_1: |-
client.index('movies').update_filterable_attributes([
'genres',
'director'
])
reset_filterable_attributes_1: |-
client.index('movies').reset_filterable_attributes()
get_searchable_attributes_1: |-
client.index('movies').get_searchable_attributes()
update_searchable_attributes_1: |-
Expand All @@ -135,11 +142,10 @@ get_displayed_attributes_1: |-
client.index('movies').get_displayed_attributes()
update_displayed_attributes_1: |-
client.index('movies').update_displayed_attributes([
"title",
'title',
'description',
'release_date',
'rank',
'poster'
'genre',
'release_date'
])
reset_displayed_attributes_1: |-
client.index('movies').reset_displayed_attributes()
Expand Down Expand Up @@ -170,19 +176,19 @@ field_properties_guide_displayed_1: |-
]})
filtering_guide_1: |-
client.index('movies').search('Avengers', {
'filters': 'release_date > 795484800'
'filter': 'release_date > 795484800'
})
filtering_guide_2: |-
client.index('movies').search('Batman', {
'filters': 'release_date > 795484800 AND (director = "Tim Burton" OR director = "Christopher Nolan")'
'filter': 'release_date > 795484800 AND (director = "Tim Burton" OR director = "Christopher Nolan")'
})
filtering_guide_3: |-
client.index('movies').search('horror', {
'filters': 'director = "Jordan Peele"'
'filter': 'director = "Jordan Peele"'
})
filtering_guide_4: |-
client.index('movies').search('Planet of the Apes', {
'filters': 'rating >= 3 AND (NOT director = "Tim Burton")'
'filter': 'rating >= 3 AND (NOT director = "Tim Burton")'
})
search_parameter_guide_query_1: |-
client.index('movies').search('shifu')
Expand All @@ -204,25 +210,23 @@ search_parameter_guide_crop_1: |-
'cropLength': 10
})
search_parameter_guide_highlight_1: |-
client.index('movies').search('shifu', {
client.index('movies').search('winter feast', {
'attributesToHighlight': ['overview']
})
search_parameter_guide_filter_1: |-
client.index('movies').search('n', {
'filters': 'title = Nightshift'
'filter': 'title = Nightshift'
})
search_parameter_guide_filter_2: |-
client.index('movies').search('n', {
'filters': 'title = "Kung Fu Panda"'
client.index('movies').search('shifu', {
'filter': 'title = "Kung Fu Panda"'
})
search_parameter_guide_matches_1: |-
client.index('movies').search('n', {
'filters': 'title = "Kung Fu Panda"',
'attributesToHighlight': ['overview'],
client.index('movies').search('winter feast', {
'matches': 'true'
})
settings_guide_synonyms_1: |-
client.index('movies').update_settings({
client.index('tops').update_settings({
'synonyms': {
sweater: ['jumper'],
jumper: ['sweater']
Expand All @@ -239,18 +243,17 @@ settings_guide_stop_words_1: |-
settings_guide_ranking_rules_1: |-
client.index('movies').update_settings({
'rankingRules': [
'typo',
'words',
'typo',
'proximity',
'attribute',
'wordsPosition',
'exactness',
'asc(release_date)',
'desc(rank)'
]
})
settings_guide_distinct_1: |-
client.index('movies').update_settings({
client.index('jackets').update_settings({
'distinctAttribute': 'product_id'
})
settings_guide_searchable_1: |-
Expand All @@ -270,6 +273,12 @@ settings_guide_displayed_1: |-
'release_date'
]
})
add_movies_json_1: |-
import json

json_file = open('movies.json')
movies = json.load(json_file)
client.index('movies').add_documents(movies)
documents_guide_add_movie_1: |-
client.index('movies').add_documents([{
'movie_id': '123sq178',
Expand All @@ -282,7 +291,7 @@ search_guide_1: |-
})
search_guide_2: |-
client.index('movies').search('Avengers', {
'filters': 'release_date > 795484800'
'filter': 'release_date > 795484800'
})
getting_started_add_documents_md: |-
```bash
Expand All @@ -308,28 +317,28 @@ getting_started_search_md: |-

[About this SDK](https://github.com/meilisearch/meilisearch-python/)
faceted_search_update_settings_1: |-
client.index('movies').update_attributes_for_faceting([
client.index('movies').update_filterable_attributes([
'director',
'genres',
])
faceted_search_facet_filters_1: |-
faceted_search_filter_1: |-
client.index('movies').search('thriller', {
'facetFilters': [['genres:Horror', 'genres:Mystery'], 'director:Jordan Peele']
'filter': [['genres = Horror', 'genres = Mystery'], 'director = "Jordan Peele"']
})
faceted_search_facets_distribution_1: |-
client.index('movies').search('Batman', {
'facetsDistribution': ['genres']
})
faceted_search_walkthrough_attributes_for_faceting_1: |-
client.index('movies').update_attributes_for_faceting([
faceted_search_walkthrough_filterable_attributes_1: |-
client.index('movies').update_filterable_attributes([
'director',
'producer',
'genres',
'production_companies'
])
faceted_search_walkthrough_facet_filters_1: |-
faceted_search_walkthrough_filter_1: |-
client.index('movies').search('thriller', {
'facetFilters': [['genres:Horror', 'genres:Mystery'], 'director:Jordan Peele']
'filter': [['genres = Horror', 'genres = Mystery'], 'director = "Jordan Peele"']
})
faceted_search_walkthrough_facets_distribution_1: |-
client.index('movies').search('Batman', {
Expand All @@ -339,18 +348,5 @@ post_dump_1: |-
client.create_dump()
get_dump_status_1: |-
client.get_dump_status('20201101-110357260')
get_attributes_for_faceting_1: |-
client.index('movies').get_attributes_for_faceting()
update_attributes_for_faceting_1: |-
client.index('movies').update_attributes_for_faceting([
'genres',
'director'
])
reset_attributes_for_faceting_1: |-
client.index('movies').reset_attributes_for_faceting()
add_movies_json_1: |-
import json

json_file = open('movies.json')
movies = json.load(json_file)
client.index('movies').add_documents(movies)
phrase_search_1: |-
client.index('movies').search('"african american" horror')
21 changes: 10 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ documents = [
index.add_documents(documents) # => { "updateId": 0 }
```

With the `updateId`, you can check the status (`enqueued`, `processed` or `failed`) of your documents addition using the [update endpoint](https://docs.meilisearch.com/reference/api/updates.html#get-an-update-status).
With the `updateId`, you can check the status (`enqueued`, `processing`, `processed` or `failed`) of your documents addition using the [update endpoint](https://docs.meilisearch.com/reference/api/updates.html#get-an-update-status).

#### Basic Search <!-- omit in toc -->

Expand Down Expand Up @@ -117,10 +117,9 @@ All the supported options are described in the [search parameters](https://docs.

```python
index.search(
'prince',
'hob',
{
'attributesToHighlight': ['title'],
'filters': 'book_id > 10'
'attributesToHighlight': ['*'],
}
)
```
Expand All @@ -131,24 +130,24 @@ JSON output:
{
"hits": [
{
"book_id": 456,
"title": "Le Petit Prince",
"book_id": 1344,
"title": "The Hobbit",
"_formatted": {
"book_id": 456,
"title": "Le Petit <em>Prince</em>"
"book_id": 1344,
"title": "The <em>Hob</em>bit"
}
}
],
"offset": 0,
"limit": 20,
"processingTimeMs": 10,
"query": "prince"
"processingTimeMs": 0,
"query": "hob"
}
```

## 🤖 Compatibility with MeiliSearch

This package only guarantees the compatibility with the [version v0.20.0 of MeiliSearch](https://github.com/meilisearch/MeiliSearch/releases/tag/v0.20.0).
This package only guarantees the compatibility with the [version v0.21.0 of MeiliSearch](https://github.com/meilisearch/MeiliSearch/releases/tag/v0.21.0).

## 💡 Learn More

Expand Down
2 changes: 1 addition & 1 deletion meilisearch/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Paths():
stop_words = 'stop-words'
synonyms = 'synonyms'
accept_new_fields = 'accept-new-fields'
attributes_for_faceting = 'attributes-for-faceting'
filterable_attributes = 'filterable-attributes'
dumps = 'dumps'

def __init__(
Expand Down
28 changes: 14 additions & 14 deletions meilisearch/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def get_all_update_status(self) -> List[Dict[str, Any]]:
Returns
-------
update:
List of all enqueued and processed actions of the index.
List of all enqueued, processing, processed or failed actions of the index.

Raises
------
Expand Down Expand Up @@ -215,7 +215,7 @@ def wait_for_pending_update(
while elapsed_time < timeout_in_ms:
get_update = self.get_update_status(update_id)

if get_update['status'] != 'enqueued':
if get_update['status'] != 'enqueued' and get_update['status'] != 'processing':
return get_update
sleep(interval_in_ms / 1000)
time_delta = datetime.now() - start_time
Expand Down Expand Up @@ -973,34 +973,34 @@ def reset_synonyms(self) -> Dict[str, int]:
self.__settings_url_for(self.config.paths.synonyms),
)

# ATTRIBUTES FOR FACETING SUB-ROUTES
# FILTERABLE ATTRIBUTES SUB-ROUTES

def get_attributes_for_faceting(self) -> List[str]:
def get_filterable_attributes(self) -> List[str]:
"""
Get attributes for faceting of the index.
Get filterable attributes of the index.

Returns
-------
settings:
List containing the attributes for faceting of the index
List containing the filterable attributes of the index

Raises
------
MeiliSearchApiError
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
"""
return self.http.get(
self.__settings_url_for(self.config.paths.attributes_for_faceting)
self.__settings_url_for(self.config.paths.filterable_attributes)
)

def update_attributes_for_faceting(self, body: List[str]) -> Dict[str, int]:
def update_filterable_attributes(self, body: List[str]) -> Dict[str, int]:
"""
Update attributes for faceting of the index.
Update filterable attributes of the index.

Parameters
----------
body:
List containing the attributes for faceting.
List containing the filterable attributes.

Returns
-------
Expand All @@ -1014,12 +1014,12 @@ def update_attributes_for_faceting(self, body: List[str]) -> Dict[str, int]:
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
"""
return self.http.post(
self.__settings_url_for(self.config.paths.attributes_for_faceting),
self.__settings_url_for(self.config.paths.filterable_attributes),
body
)

def reset_attributes_for_faceting(self) -> Dict[str, int]:
"""Reset attributes for faceting of the index to default values.
def reset_filterable_attributes(self) -> Dict[str, int]:
"""Reset filterable attributes of the index to default values.

Returns
-------
Expand All @@ -1033,7 +1033,7 @@ def reset_attributes_for_faceting(self) -> Dict[str, int]:
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
"""
return self.http.delete(
self.__settings_url_for(self.config.paths.attributes_for_faceting),
self.__settings_url_for(self.config.paths.filterable_attributes),
)

@staticmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ def test_get_version(client):
response = client.get_version()
assert 'pkgVersion' in response
assert 'commitSha' in response
assert 'buildDate' in response
assert 'commitDate' in response
Loading