Skip to content
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

Exists key in filter has a bug #4632

Closed
mhgolij opened this issue May 14, 2024 · 4 comments
Closed

Exists key in filter has a bug #4632

mhgolij opened this issue May 14, 2024 · 4 comments
Labels
needs more info This issue needs a minimal complete and verifiable example

Comments

@mhgolij
Copy link

mhgolij commented May 14, 2024

Describe the bug
When I use the Exists keyword on an object, the data is returned correctly. However, when I change one of the returned data and make sure it is not part of the filter, it still appears in the results.

Example
For example, I have a data with the following format:

{
  id:22323,
  categories: {
    "144":"novel",
    "2":"poetry"
  }
}

When I use the filter "categories.144 Exists," I expect the above data to be part of the results, which happens. But when I subsequently modify the data as follows:

{
  id:22323,
  categories: {
    "2":"poetry"
  }
}

And use the same filter, this data still appears as part of the result (although the data itself is displayed correctly).

The point is that this issue does not exist with keywords like IN, so if I change my document to following structure:

{
  id:22323,
  categories:{
    "2": "poetry"
  },
  categories_id:{
    0:2
  }
}

and change my filter to "categories_id IN [144]' this work correctly

Meilisearch version:
v1.8.0

Additional context
using meilisearch php

@Kerollmops
Copy link
Member

Hey @mhgolij 👋

I just tried your example (with this single document) on a 1.8.0 version of Meilisearch, and it works as expected on my side. Can you provide your dataset (that you sent by email) reproduce correctly?

# Send your document with a categories.144 set to novel
curl -X POST 'http://localhost:7700//indexes/books/documents' \
  --header 'Content-Type: application/json' \
  --data-raw $'[{ "id": 22323, "categories": { "144": "novel", "2": "poetry"}}]'

# Specify that the categories (and subfields) are filterable
curl -X PATCH 'http://localhost:7700//indexes/books/settings' \
  --header 'Content-Type: application/json' \
  --data-raw $'{ "filterableAttributes": ["categories"] }'

# Check that it returns our document (it does 🎉)
curl -X POST 'http://localhost:7700//indexes/books/search' \
  --header 'Content-Type: application/json' \
  --data-raw $'{"filter": "categories.144 EXISTS" }'

# Update the document to remove the categories.144 field
curl -X POST 'http://localhost:7700//indexes/books/documents' \
  --header 'Content-Type: application/json' \
  --data-raw $'[{"id": 22323, "categories": {"2": "poetry"}}]'

# Execute the query again and see that the document is no longer there (🎉)
curl -X POST 'http://localhost:7700//indexes/books/search' \
  --header 'Content-Type: application/json' \
  --data-raw $'{"filter": "categories.144 EXISTS"}'

@curquiza curquiza added the needs more info This issue needs a minimal complete and verifiable example label May 16, 2024
@mhgolij
Copy link
Author

mhgolij commented May 18, 2024

Hey @Kerollmops

This is very strange. I also tested the code and the result was correct. I even placed this data in a loop of 30,000 iterations, and the result was still correct. However, the result is still incorrect with the original data...

@Kerollmops
Copy link
Member

Thank you @mhgolij,

I think it is a bug, but now we need to find the right reproducer. Please provide the dataset or maybe a dump of your dataset.

Also, what is your typical use case with Meilisearch? How do you send your documents, update them, etc.?

@Kerollmops
Copy link
Member

I am closing this issue as we cannot reproduce the bug. Feel free to reopen with a complete reproducer if it happens again.

@Kerollmops Kerollmops closed this as not planned Won't fix, can't repro, duplicate, stale May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more info This issue needs a minimal complete and verifiable example
Projects
None yet
Development

No branches or pull requests

3 participants