Skip to content

Implements the EXISTS filter #2484

@irevoire

Description

@irevoire

After the following discussion and a meeting with @gmourier and @loiclec; https://github.com/meilisearch/product/issues/22

The first version of the filter should be implemented with the following syntax;

The keyword is postfixed
       vvvvv
 price EXISTS
^     ^
A NOT can be prefixed or infixed
vvv       vvv
NOT price NOT EXISTS

With the following set of documents;

{ "id": 1, "product": "T-shirt", "price": 20, "color": "yellow" }
{ "id": 2, "product": "T-shirt", "color": "red" }
  • The filter price EXISTS will select the first document.
  • The filter price NOT EXISTS or NOT price EXISTS will select only the second document.

If a field contains an empty array or a null value, it's considered as existing:

{ "id": 1, "product": "T-shirt", "price": 20, "color": "yellow" }
{ "id": 2, "product": "T-shirt", "price": [], "color": "red" }
{ "id": 3, "product": "T-shirt", "price": null, "color": "red" }
{ "id": 4, "product": "T-shirt", "color": "red" }

Here price EXISTS matches documents 1, 2 and 3.


This will ease the handling of incomplete documents. For example, if you want to return all T-shirt that cost less than 20€ or that doesn't have a price specified, you will be able to write product = "T-shirt" AND (price < 20 OR price NOT EXISTS).
That was not possible previously.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or improvementimpacts docsThis issue involves changes in the Meilisearch's documentationimpacts integrationsThis issue involves changes in the Meilisearch's integrationsmilliRelated to the milli workspacev0.29.0PRs/issues solved in v0.29.0 released on 2022-10-03

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions