-
Notifications
You must be signed in to change notification settings - Fork 90
Add ability to get documents with a filter #757
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
Conversation
@@ -308,6 +308,7 @@ def get_documents(self, parameters: Optional[Dict[str, Any]] = None) -> Document | |||
---------- | |||
parameters (optional): | |||
parameters accepted by the get documents route: https://docs.meilisearch.com/reference/api/documents.html#get-documents | |||
Note: The filter parameter is only available in Meilisearch >= 1.2.0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌
meilisearch/index.py
Outdated
response = self.http.get( | ||
f"{self.config.paths.index}/{self.uid}/{self.config.paths.document}?{parse.urlencode(parameters)}" | ||
) | ||
return DocumentsResults(response) | ||
|
||
if not parameters.get("filter"): | ||
if "fields" in parameters and isinstance(parameters["fields"], list): | ||
parameters["fields"] = ",".join(parameters["fields"]) | ||
|
||
response = self.http.get( | ||
f"{self.config.paths.index}/{self.uid}/{self.config.paths.document}?{parse.urlencode(parameters)}" | ||
response = self.http.get( | ||
f"{self.config.paths.index}/{self.uid}/{self.config.paths.document}?{parse.urlencode(parameters)}" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can find a way to avoid having to write two times the get request
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I wasn't happy with that either. I refactored it. It's still slightly more verbose than I would like, but because of the way it is using the dictionary for parameters I had a hard time coming up with something better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect 🤩 Thanks you @sanders41
LGTM!
755: Changes related to the next Meilisearch release (v1.2.0) r=alallema a=meili-bot Related to this issue: meilisearch/integration-guides#261 This PR: - gathers the changes related to the next Meilisearch release (v1.2.0) so that this package is ready when the official release is out. - should pass the tests against the [latest pre-release of Meilisearch](https://github.com/meilisearch/meilisearch/releases). - might eventually contain test failures until the Meilisearch v1.2.0 is out.⚠️ This PR should NOT be merged until the next release of Meilisearch (v1.2.0) is out. _This PR is auto-generated for the [pre-release week](https://github.com/meilisearch/integration-guides/blob/main/resources/pre-release-week.md) purpose._ Done: - #756 - #757 Co-authored-by: meili-bot <[email protected]> Co-authored-by: Paul Sanders <[email protected]> Co-authored-by: Amélie <[email protected]> Co-authored-by: alallema <[email protected]>
772: Update version for the next release (v0.28.0) r=alallema a=meili-bot Release CHANGELOG: This version introduces features released on Meilisearch v1.2.0 🎉 Check out the changelog of [Meilisearch v1.2.0](https://github.com/meilisearch/meilisearch/releases/tag/v1.2.0) for more information on the changes.⚠️ If you want to adopt new features of this release, **update the Meilisearch server** to the according version. ## 🚀 Enhancements * The method `delete_documents()` now supports a new parameter `filter` that allows deleting documents by filtering. The `filter` field works precisely like the `filter` field used on the `search` method. See [the docs on how to use filters](https://www.meilisearch.com/docs/learn/advanced/filtering#filter-basics). (#756) `@sanders41` * Add the ability to receive a `filter` key from the `get_documents`/`documents` methods. The `filter` field works precisely like the `filter` field used on the `search` method. See [the docs on how to use filters](https://www.meilisearch.com/docs/learn/advanced/filtering#filter-basics). (#757) `@sanders41` Thanks again to `@sanders41!` 🎉 Co-authored-by: meili-bot <[email protected]> Co-authored-by: Amélie <[email protected]>
Pull Request
Note: There is still some discussion about the best way to handle this so it may need some updates.
Related issue
Fixes #<issue_number>
What does this PR do?
filter
to the parameters forget_documents
PR checklist
Please check if your PR fulfills the following requirements:
Thank you so much for contributing to Meilisearch!