meilisearch-swift
meilisearch-swift copied to clipboard
Get documents by filter
⚠️ This issue is generated, it means the examples and the namings do not necessarily correspond to the language of this repository. Also, if you are a maintainer, feel free to add any clarification and instruction about this issue.
Sorry if this is already partially/completely implemented, feel free to let me know about the state of this issue in the repo.
Related to https://github.com/meilisearch/integration-guides/issues/261
This issue is divided in two sections, first you need to make the implementation, second you must update the code-samples (no one likes a outdated docs, right?).
New implementation
Related to:
- issue: https://github.com/meilisearch/meilisearch/issues/3477
- spec: https://github.com/meilisearch/specifications/pull/234
Gives the user the possibility to use a filter expression to retrieve documents, like in search.
Implement in the getDocuments method an internal conditional allowing the user to query the documents with the same method but using a new filter method.
When the user calls the get documents method with a filter argument, request POST /indexes/{index_uid}/documents/fetch using a JSON body containing an int offset, int limit, String[] fields and now String filter or String[] filter.
⚠️ If the method invocation does not contain a filter it should still call the previous implementation.
Code samples:
Inside of this file: .code-samples.meilisearch.yml:
- Replace this key:
get_documents_1:content to use thefiltergenres=action, keep theindex nameand thelimitjust add thefilter. Use this as a reference if the previous description was not helpful::
get_documents_1: |-
GET 'http://localhost:7700/indexes/movies/documents?limit=2&filter=genres=action
mind the filter in the query param (use the POST route in the integrations)
- Create a new entry with this key
get_documents_post_1:containing a call to thegetDocumentsmethod using the new behavior from the indexmoviesusing thefilterparam with this string"genres = action OR genres = adventure".
Use this as a reference if the previous description was not helpful:
get_documents_post_1: |-
POST http://localhost:7700/indexes/books/documents/fetch
with data: {
"filter": "(rating > 3 AND (genres = Adventure OR genres = Fiction)) AND language = English",
"fields": ["title", "genres", "rating", "language"],
"limit": 3
}
Todo:
- [ ] Implement the
getDocumentsnew behavior keeping the old behavior when possible. - [ ] Update the code-samples according to this issue.