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

Introduce the filter syntax for CONTAINS, STARTS and ENDS WITH #3751

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

Kerollmops
Copy link
Member

@Kerollmops Kerollmops commented May 15, 2023

This PR introduces three filters. These filters give more control over the facet string values, with can be powerful in certain situations. Keep in mind that there are performance issues with both the CONTAINS and ENDS WITH filters. It is algorithmically impossible to fix the CONTAINS one.

Related to meilisearch/product#544.

Mini Spec

The CONTAINS filter

⚠️ Performance issues can occur when the total number of facet values to filter are high
📝 Can't be improved

  • CONTAINS matches fields that EXISTS and contains a specific string inside
  • NOT CONTAINS matches fields that NOT EXISTS OR do not contain a specific string
  1. {"name":"A", "company": "Airbus 2000"}
  2. {"name":"B", "company": "Tesla Inc"}
  3. {"name":"C", "company": "Meilisearch"}
  4. {"name":"D"}

company CONTAINS 'meilisearch' would match 3
company NOT CONTAINS "meilisearch" or NOT company CONTAINS meilisearch would match 1,2,4
company CONTAINS a would match 1,2,3
company NOT CONTAINS microsoft or NOT company CONTAINS microsoft would match 1,2,3,4

common query : (company CONTAINS meilisearch) OR (company NOT EXISTS) would match 3,4

The STARTS WITH filter

📝 Can be sped up by using the levels/layers structures

  • STARTS WITH matches fields that EXISTS and starts with a specific string inside
  • NOT STARTS WITH matches fields that NOT EXISTS OR do not starts with a specific string
  1. {"name":"A", "company": "Airbus 2000"}
  2. {"name":"B", "company": "Tesla Inc"}
  3. {"name":"C", "company": "Meilisearch"}
  4. {"name":"D"}

company STARTS WITH 'meili' would match 3
company NOT STARTS WITH "meili" or NOT company STARTS WITH meili would match 1,2,4
company STARTS WITH a would match 1,2,3
company NOT STARTS WITH micro or NOT company STARTS WITH micro would match 1,2,3,4

common query : (company STARTS WITH meili) OR (company NOT EXISTS) would match 3,4

The ENDS WITH filter

⚠️ Performance issues can occur when the total number of facet values to filter are high
📝 Can be improved by duplicating the entire database and swap the strings chars

  • ENDS WITH matches fields that EXISTS and ends with a specific string inside
  • NOT ENDS WITH matches fields that NOT EXISTS OR do not ends with a specific string
  1. {"name":"A", "company": "Airbus 2000"}
  2. {"name":"B", "company": "Tesla Inc"}
  3. {"name":"C", "company": "Meilisearch"}
  4. {"name":"D"}

company ENDS WITH 'search' would match 3
company NOT ENDS WITH "search" or NOT company ENDS WITH search would match 1,2,4
company ENDS WITH a would match 1,2,3
company NOT ENDS WITH soft or NOT company ENDS WITH soft would match 1,2,3,4

common query : (company ENDS WITH search) OR (company NOT EXISTS) would match 3,4

Todo List

@Kerollmops Kerollmops force-pushed the contains-starts-ends-with-filters branch from ceb34ed to bdcee66 Compare May 16, 2023 08:32
@Kerollmops Kerollmops force-pushed the contains-starts-ends-with-filters branch from 74336cf to 72f4b8f Compare May 16, 2023 08:53
@Kerollmops Kerollmops force-pushed the contains-starts-ends-with-filters branch from 66d3389 to 5e12ed3 Compare May 16, 2023 11:59
@Kerollmops Kerollmops added the prototype available You can test this feature using the available prototype label May 16, 2023
@gillian-meilisearch gillian-meilisearch linked an issue Jun 19, 2023 that may be closed by this pull request
3 tasks
@GelistirmeKF
Copy link

This issue is so important for us. When will it be released?

Thanks,
KF

@curquiza
Copy link
Member

Hello @GelistirmeKF

Thanks for letting us know. What is your use case exactly? You need this feature, but can you describe more about what you need?
Please feel free to tell us about your use case and the details of it in this related product discussion and not in the PR. Our product team will be able to manage your request 😊

@GelistirmeKF
Copy link

Hi @curquiza,

I mentioned it in this meilisearch/product#544 and but didn't get any response.

Thanks in advance,
KF

@2567910
Copy link

2567910 commented Sep 27, 2023

When will this be available?

@curquiza
Copy link
Member

Hello everyone

This feature is not planned yet. We encountered performance issues when we created this prototype
I always recommend referring to the related discussion to talk about your needs and expectations
This PR discussion is for technical details 😊

Thank you in advance

@james2001
Copy link

Hi

Any news about this feature?

@curquiza
Copy link
Member

curquiza commented Apr 4, 2024

Hello @james2001

It's not planned at the moment
We encountered performance issues when we created this prototype and it's not in our priority for the moment.
I always recommend referring to the meilisearch/product#544 to talk about your needs and expectations, and asking some updates about the feature.

As a reminder, this PR discussion is for technical details 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
prototype available You can test this feature using the available prototype
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CONTAINS filter operator
5 participants