Skip to content

Commit aeac667

Browse files
authored
Merge branch 'main' into bump-meilisearch-v0.23.0
2 parents 90430bf + 35a2962 commit aeac667

File tree

5 files changed

+124
-65
lines changed

5 files changed

+124
-65
lines changed

CONTRIBUTING.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ It's [Hacktoberfest month](https://blog.meilisearch.com/contribute-hacktoberfest
1515

1616
🚀 If your PR gets accepted it will count into your participation to Hacktoberfest!
1717

18-
✅ To be accepted it has either to have been merged, approved or tagged with the `hacktoberest-accepted` label.
18+
✅ To be accepted it has either to have been merged, approved or tagged with the `hacktoberfest-accepted` label.
1919

20-
🧐 Don't forget to check the [quality standards](https://hacktoberfest.digitalocean.com/resources/qualitystandards), otherwise your PR could be marked as `spam` or `invalid`, and it will not be counted toward your participation in Hacktoberfest.
20+
🧐 Don't forget to check the [quality standards](https://hacktoberfest.digitalocean.com/resources/qualitystandards)! Low-quality PRs might get marked as `spam` or `invalid`, and will not count toward your participation in Hacktoberfest.
2121

2222
## Assumptions
2323

@@ -30,7 +30,7 @@ It's [Hacktoberfest month](https://blog.meilisearch.com/contribute-hacktoberfest
3030
1. Make sure that the contribution you want to make is explained or detailed in a GitHub issue! Find an [existing issue](https://github.com/meilisearch/meilisearch-python/issues/) or [open a new one](https://github.com/meilisearch/meilisearch-python/issues/new).
3131
2. Once done, [fork the meilisearch-python repository](https://help.github.com/en/github/getting-started-with-github/fork-a-repo) in your own GitHub account. Ask a maintainer if you want your issue to be checked before making a PR.
3232
3. [Create a new Git branch](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-and-deleting-branches-within-your-repository).
33-
4. Review the [Development Workflow](#workflow) section that describes the steps to maintain the repository.
33+
4. Review the [Development Workflow](#development-workflow) section that describes the steps to maintain the repository.
3434
5. Make the changes on your branch.
3535
6. [Submit the branch as a PR](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork) pointing to the `main` branch of the main meilisearch-python repository. A maintainer should comment and/or review your Pull Request within a few days. Although depending on the circumstances, it may take longer.<br>
3636
We do not enforce a naming convention for the PRs, but **please use something descriptive of your changes**, having in mind that the title of your PR will be automatically added to the next [release changelog](https://github.com/meilisearch/meilisearch-python/releases/).
@@ -103,7 +103,7 @@ Some notes on GitHub PRs:
103103

104104
- [Convert your PR as a draft](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/changing-the-stage-of-a-pull-request) if your changes are a work in progress: no one will review it until you pass your PR as ready for review.<br>
105105
The draft PR can be very useful if you want to show that you are working on something and make your work visible.
106-
- The branch related to the PR must be **up-to-date with `main`** before merging. Fortunately, this project [integrates a bot](https://github.com/meilisearch/integration-guides/blob/main/guides/bors.md) to automatically enforce this requirement without the PR author having to do it manually..
106+
- The branch related to the PR must be **up-to-date with `main`** before merging. Fortunately, this project [integrates a bot](https://github.com/meilisearch/integration-guides/blob/main/guides/bors.md) to automatically enforce this requirement without the PR author having to do it manually.
107107
- All PRs must be reviewed and approved by at least one maintainer.
108108
- The PR title should be accurate and descriptive of the changes. The title of the PR will be indeed automatically added to the next [release changelogs](https://github.com/meilisearch/meilisearch-python/releases/).
109109

Pipfile.lock

Lines changed: 39 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,18 @@ import meilisearch
7272
client = meilisearch.Client('http://127.0.0.1:7700', 'masterKey')
7373

7474
# An index is where the documents are stored.
75-
index = client.index('books')
75+
index = client.index('movies')
7676

7777
documents = [
78-
{ 'book_id': 123, 'title': 'Pride and Prejudice' },
79-
{ 'book_id': 456, 'title': 'Le Petit Prince' },
80-
{ 'book_id': 1, 'title': 'Alice In Wonderland' },
81-
{ 'book_id': 1344, 'title': 'The Hobbit' },
82-
{ 'book_id': 4, 'title': 'Harry Potter and the Half-Blood Prince' },
83-
{ 'book_id': 42, 'title': 'The Hitchhiker\'s Guide to the Galaxy' }
78+
{ id: 1, title: 'Carol', genres: ['Romance', 'Drama'] },
79+
{ id: 2, title: 'Wonder Woman', genres: ['Action', 'Adventure'] },
80+
{ id: 3, title: 'Life of Pi', genres: ['Adventure', 'Drama'] },
81+
{ id: 4, title: 'Mad Max: Fury Road', genres: ['Adventure', 'Science Fiction'] },
82+
{ id: 5, title: 'Moana', genres: ['Fantasy', 'Action']},
83+
{ id: 6, title: 'Philadelphia', genres: ['Drama'] },
8484
]
8585

86-
# If the index 'books' does not exist, MeiliSearch creates it when you first add the documents.
86+
# If the index 'movies' does not exist, MeiliSearch creates it when you first add the documents.
8787
index.add_documents(documents) # => { "updateId": 0 }
8888
```
8989

@@ -93,21 +93,24 @@ With the `updateId`, you can check the status (`enqueued`, `processing`, `proces
9393

9494
``` python
9595
# MeiliSearch is typo-tolerant:
96-
index.search('harry pottre')
96+
index.search('caorl')
9797
```
9898

9999
Output:
100100

101-
```python
101+
```json
102102
{
103-
"hits" => [{
104-
"book_id" => 4,
105-
"title" => "Harry Potter and the Half-Blood Prince"
106-
}],
107-
"offset" => 0,
108-
"limit" => 20,
109-
"processingTimeMs" => 1,
110-
"query" => "harry pottre"
103+
"hits": [
104+
{
105+
"id": 1,
106+
"title": "Carol",
107+
"genre": ["Romance", "Drama"]
108+
}
109+
],
110+
"offset": 0,
111+
"limit": 20,
112+
"processingTimeMs": 1,
113+
"query": "caorl"
111114
}
112115
```
113116

@@ -117,7 +120,7 @@ All the supported options are described in the [search parameters](https://docs.
117120

118121
```python
119122
index.search(
120-
'hob',
123+
'phil',
121124
{
122125
'attributesToHighlight': ['*'],
123126
}
@@ -130,18 +133,19 @@ JSON output:
130133
{
131134
"hits": [
132135
{
133-
"book_id": 1344,
134-
"title": "The Hobbit",
136+
"id": 6,
137+
"title": "Philadelphia",
135138
"_formatted": {
136-
"book_id": 1344,
137-
"title": "The <em>Hob</em>bit"
139+
"id": 6,
140+
"title": "<em>Phil</em>adelphia",
141+
"genre": ["Drama"]
138142
}
139143
}
140144
],
141145
"offset": 0,
142146
"limit": 20,
143147
"processingTimeMs": 0,
144-
"query": "hob"
148+
"query": "phil"
145149
}
146150
```
147151

datasets/small_movies.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,5 +218,13 @@
218218
"poster": "https://image.tmdb.org/t/p/w1280/oeZh7yEz3PMnZLgBPhrafFHRbVz.jpg",
219219
"overview": "Earl Stone, a man in his 80s who is broke, alone, and facing foreclosure of his business when he is offered a job that simply requires him to drive. Easy enough, but, unbeknownst to Earl, he’s just signed on as a drug courier for a Mexican cartel. He does so well that his cargo increases exponentially, and Earl hit the radar of hard-charging DEA agent Colin Bates.",
220220
"release_date": 1544745600
221+
},
222+
{
223+
"id": "123456",
224+
"title": "Hitchhiker's Guide to the Galaxy",
225+
"poster": "https://www.themoviedb.org/t/p/w1280/yKiH7IIbo23uA72MmY318mXorjw.jpg",
226+
"overview": "Don't Panic! The story of Arthur Dent, an average Englishman who life was spared by his friend, who turned out to be an alien, while the planet Earth is destroyed. His friend tells him about the Hitchhiker's Guide to the Galaxy, a guide with anything you ever needed, and wanted to know. They travel across the galaxy, meeting friendly, and not so friendly characters in order to find the great question (the answer being 42).",
227+
"release_date": 1114669984,
228+
"genre": "Sci Fi"
221229
}
222230
]

meilisearch/tests/index/test_index_search_meilisearch.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,51 @@ def test_custom_search_params_with_filter_string(index_with_documents):
148148
assert 'facetsDistribution' not in response
149149
assert 'exhaustiveFacetsCount' not in response
150150

151+
def test_custom_search_params_with_filter_string_with_space(index_with_documents):
152+
index = index_with_documents()
153+
update = index.update_filterable_attributes(['genre'])
154+
index.wait_for_pending_update(update['updateId'])
155+
response = index.search(
156+
'galaxy',
157+
{
158+
'filter': "genre = 'sci fi'"
159+
}
160+
)
161+
assert isinstance(response, dict)
162+
assert len(response['hits']) == 1
163+
assert 'facetsDistribution' not in response
164+
assert 'exhaustiveFacetsCount' not in response
165+
166+
def test_custom_search_params_with_multiple_filter_string_with_space(index_with_documents):
167+
index = index_with_documents()
168+
update = index.update_filterable_attributes(['genre', 'release_date'])
169+
index.wait_for_pending_update(update['updateId'])
170+
response = index.search(
171+
'galaxy',
172+
{
173+
'filter': "genre = 'sci fi' AND release_date < 1550000000"
174+
}
175+
)
176+
assert isinstance(response, dict)
177+
assert len(response['hits']) == 1
178+
assert 'facetsDistribution' not in response
179+
assert 'exhaustiveFacetsCount' not in response
180+
181+
def test_custom_search_params_with_array_filter_with_space(index_with_documents):
182+
index = index_with_documents()
183+
update = index.update_filterable_attributes(['genre', 'release_date'])
184+
index.wait_for_pending_update(update['updateId'])
185+
response = index.search(
186+
'galaxy',
187+
{
188+
"filter": ["genre = 'sci fi'", "release_date < 1550000000"]
189+
}
190+
)
191+
assert isinstance(response, dict)
192+
assert len(response['hits']) == 1
193+
assert 'facetsDistribution' not in response
194+
assert 'exhaustiveFacetsCount' not in response
195+
151196
def test_custom_search_params_with_mutilple_filter_string(index_with_documents):
152197
index = index_with_documents()
153198
update = index.update_filterable_attributes(['genre', 'release_date'])

0 commit comments

Comments
 (0)