meilisearch-swift icon indicating copy to clipboard operation
meilisearch-swift copied to clipboard

Get documents by filter

Open brunoocasali opened this issue 2 years ago • 0 comments
trafficstars

⚠️ 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:

  1. Replace this key: get_documents_1: content to use the filter genres=action, keep the index name and the limit just add the filter. 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)
  1. Create a new entry with this key get_documents_post_1: containing a call to the getDocuments method using the new behavior from the index movies using the filter param 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 getDocuments new behavior keeping the old behavior when possible.
  • [ ] Update the code-samples according to this issue.

brunoocasali avatar Jun 05 '23 18:06 brunoocasali