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

Allow complex filtering on the code (startswith, endswith, contains, regex) #242

Open
raphodn opened this issue Sep 4, 2024 · 2 comments

Comments

@raphodn
Copy link
Member

raphodn commented Sep 4, 2024

Story

For Open Prices - https://github.com/openfoodfacts/open-prices - when adding prices, we sometimes struggle to read the barcodes on our proof images. See related Slack discussion here

A feature that would help is additional filtering on the code field, such as :

// pseudo-code (dunno how it would translate into Lucene ^^)
search?code__startswith=123456
search?code__endswith=890
search?code__contains=45678
search?code__match=X000X00179X64

Examples

Image Query
image search?code__match=X000X00179X64
image search?code__contains=81714&brand=Picard
@alexgarel
Copy link
Member

alexgarel commented Sep 6, 2024

@raphodn in my refactor PR, I added better support for wildcard.

So as long as you have a keyword field (like the code) you will be able do:

  • code:123456*
  • code:*890
  • code:*45678*
  • code:*000*00179*64

For regexp matching I don't remember if luqum supports it and I'm not sure if it's a good idea to activate it ;-) (I have to re-read ES considerations on it, we could maybe also make it configurable, so that it's activated only on certain field (thanks to luqum it's easy to check for that)).

@raphodn
Copy link
Member Author

raphodn commented Sep 8, 2024

Did a quick test :

https://search.openfoodfacts.org/search?q=code:*81714*
// 113 hits..

https://search.openfoodfacts.org/search?q=code:*81714* brands:picard
// 1 hit :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog (ready for dev)
Development

No branches or pull requests

2 participants