Skip to content

Commit f609f62

Browse files
authored
Merge branch 'main' into dependabot/pip/types-requests-2.25.11
2 parents 57abf6e + c072e09 commit f609f62

File tree

5 files changed

+61
-19
lines changed

5 files changed

+61
-19
lines changed

.code-samples.meilisearch.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ list_all_indexes_1: |-
1010
create_an_index_1: |-
1111
client.create_index('movies', {'primaryKey': 'movie_id'})
1212
update_an_index_1: |-
13-
client.index('movies').update(primaryKey='movie_review_id')
13+
client.index('movies').update(primary_key='movie_review_id')
1414
delete_an_index_1: |-
1515
client.index('movies').delete()
1616
get_one_document_1: |-
@@ -120,11 +120,11 @@ update_ranking_rules_1: |-
120120
reset_ranking_rules_1: |-
121121
client.index('movies').reset_ranking_rules()
122122
get_distinct_attribute_1: |-
123-
client.index('movies').get_distinct_attribute()
123+
client.index('shoes').get_distinct_attribute()
124124
update_distinct_attribute_1: |-
125-
client.index('movies').update_distinct_attribute('movie_id')
125+
client.index('shoes').update_distinct_attribute('skuid')
126126
reset_distinct_attribute_1: |-
127-
client.index('movies').reset_distinct_attribute()
127+
client.index('shoes').reset_distinct_attribute()
128128
get_filterable_attributes_1: |-
129129
client.index('movies').get_filterable_attributes()
130130
update_filterable_attributes_1: |-

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ Each PR should pass the tests, mypy type checking, and the linter to be accepted
4949

5050
```bash
5151
# Tests
52-
docker pull getmeili/meilisearch:latest # Fetch the latest version of MeiliSearch image from Docker Hub
53-
docker run -p 7700:7700 getmeili/meilisearch:latest ./meilisearch --master-key=masterKey --no-analytics=true
52+
curl -L https://install.meilisearch.com | sh # download MeiliSearch
53+
./meilisearch --master-key=masterKey --no-analytics=true # run MeiliSearch
5454
pipenv run pytest meilisearch
5555
# MyPy
5656
pipenv run mypy meilisearch

README.md

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,17 @@ pip3 install meilisearch
5353

5454
There are many easy ways to [download and run a MeiliSearch instance](https://docs.meilisearch.com/reference/features/installation.html#download-and-launch).
5555

56-
For example, if you use Docker:
56+
For example, using the `curl` command in [your Terminal](https://itconnect.uw.edu/learn/workshops/online-tutorials/web-publishing/what-is-a-terminal/):
5757

5858
```bash
59-
docker pull getmeili/meilisearch:latest # Fetch the latest version of MeiliSearch image from Docker Hub
60-
docker run -it --rm -p 7700:7700 getmeili/meilisearch:latest ./meilisearch --master-key=masterKey
59+
# Install MeiliSearch
60+
curl -L https://install.meilisearch.com | sh
61+
62+
# Launch MeiliSearch
63+
./meilisearch --master-key=masterKey
6164
```
6265

63-
NB: you can also download MeiliSearch from **Homebrew** or **APT**.
66+
NB: you can also download MeiliSearch from **Homebrew** or **APT** or even run it using **Docker**.
6467

6568
## 🚀 Getting Started
6669

@@ -149,6 +152,49 @@ JSON output:
149152
}
150153
```
151154

155+
#### Custom Search With Filters <!-- omit in toc -->
156+
157+
If you want to enable filtering, you must add your attributes to the `filterableAttributes` index setting.
158+
159+
```py
160+
index.update_filterable_attributes([
161+
'id',
162+
'genres'
163+
])
164+
```
165+
166+
You only need to perform this operation once.
167+
168+
Note that MeiliSearch will rebuild your index whenever you update `filterableAttributes`. Depending on the size of your dataset, this might take time. You can track the process using the [update status](https://docs.meilisearch.com/reference/api/updates.html#get-an-update-status).
169+
170+
Then, you can perform the search:
171+
172+
```py
173+
index.search(
174+
'wonder',
175+
{
176+
filter: ['id > 1 AND genres = Action']
177+
}
178+
)
179+
```
180+
181+
```json
182+
{
183+
"hits": [
184+
{
185+
"id": 2,
186+
"title": "Wonder Woman",
187+
"genres": ["Action","Adventure"]
188+
}
189+
],
190+
"offset": 0,
191+
"limit": 20,
192+
"nbHits": 1,
193+
"processingTimeMs": 0,
194+
"query": "wonder"
195+
}
196+
```
197+
152198
## 🤖 Compatibility with MeiliSearch
153199

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

meilisearch/index.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,24 +74,20 @@ def delete_if_exists(self) -> bool:
7474
raise error
7575
return False
7676

77-
def update(self, **body: Dict[str, Any]) -> 'Index':
77+
def update(self, primary_key: str) -> 'Index':
7878
"""Update the index primary-key.
7979
8080
Parameters
8181
----------
82-
body:
83-
Accepts primaryKey as an updatable parameter.
84-
Ex: index.update(primaryKey='name')
82+
primary_key:
83+
The primary key to use for the index.
8584
8685
Raises
8786
------
8887
MeiliSearchApiError
8988
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
9089
"""
91-
payload = {}
92-
primary_key = body.get('primaryKey')
93-
if primary_key is not None:
94-
payload['primaryKey'] = primary_key
90+
payload = {'primaryKey': primary_key}
9591
response = self.http.put(f'{self.config.paths.index}/{self.uid}', payload)
9692
self.primary_key = response['primaryKey']
9793
self.created_at = self._iso_to_date_time(response['createdAt'])

meilisearch/tests/index/test_index.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def test_get_primary_key(client):
163163
def test_update_index(client):
164164
"""Tests updating an index."""
165165
index = client.index(uid=common.INDEX_UID)
166-
response = index.update(primaryKey='objectID')
166+
response = index.update(primary_key='objectID')
167167
assert isinstance(response, Index)
168168
assert index.primary_key == 'objectID'
169169
assert index.get_primary_key() == 'objectID'

0 commit comments

Comments
 (0)