meilisearch / meilisearch-java

Java client for Meilisearch

Home Page:https://meilisearch.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Get documents by filter

brunoocasali opened this issue · comments

⚠️ 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 meilisearch/integration-guides#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:

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. Update get_documents_1:
    Refer to this curl example: https://github.com/meilisearch/documentation/blob/e4fdc3d485c22e31a045b8a71bacf18b6a7d50e0/.code-samples.meilisearch.yaml#L30C1-L30C16

  2. Create a new entry with this key get_documents_post_1:
    Refer to this curl example: https://github.com/meilisearch/documentation/blob/e4fdc3d485c22e31a045b8a71bacf18b6a7d50e0/.code-samples.meilisearch.yaml#L1043

Todo:

  • Implement the getDocuments new behavior keeping the old behavior when possible.
  • Update the code-samples according to this issue.

I would like to work on this @brunoocasali.

I was going through the codebase, and wanted to confirm that:
In the latest version of Meilisearch 1.7.x, I see that fields and filter parameters are no longer accepted as query param(reference: https://www.meilisearch.com/docs/reference/api/search#filter) but are accepted via request body. So I will need to make changes accordingly, is that understanding correct?

Hello @bhupixb
I think you are refering to the wrong route.
It's not /search but /documents -> https://www.meilisearch.com/docs/reference/api/documents#get-documents-with-post

@curquiza Thanks for the quick response.
My bad, that I attached the wrong API reference but in the doc you shared, there also fields and filter etc are expected in the Request Body and not via params. I verified this locally by calling the API and I can see passing filter in params have no effect on search results but passing the filter in the request body does.
So I hope my above question is still valid regarding the changes to be done.

@overkillerBhupendra fields and filters have never been accepted as parameters, but only in the body as POST request. The issue does not mention parameters. Maybe I miss understand something, in this case, by bad!

The point of this issue is to add the ability to filter documents via the POST /documents route by using the request body.

Just wanted to follow up on this PR #724 . I know it's been a month since I submitted it, and I completely understand if you guys are busy. I was hoping to check if you had a chance to review it or if there's any additional information I can provide to help with the process.

Hello @bhupixb
That's my fault, I'm very sorry, I'm really busy. I can understand it's frustrating for contributors. I will ensure to prioritize this review next week 🤞