openfoodfacts / search-a-licious

🍊🔎 A pluggable search service for large collections of objects (like Open Food Facts)
https://search.openfoodfacts.org
GNU Affero General Public License v3.0
6 stars 4 forks source link

Make search queries more coherents #193

Open alexgarel opened 4 days ago

alexgarel commented 4 days ago

We are trying to abstract out complexity of Elasticsearch through a configuration and Lucene query language.

Right now this abstraction is quite leaky. For example if you declare labels as a text_lang field, you should query, eg. labels.en:"my query" to reach it. While you also specify which language you want to query with. There are a number of other problems of this type.

Most of those problems can be solved by using Lucene to modify the request on the fly, based upon field deficinition

### To be fixed
- [ ] replace text_lang field with right expression on the fly (eg labels: --> labels.en:)
- [ ] treat phrase match as word match (use all text search fields)
- [ ] explore using the synonyms feature of elasticsearch instead of injecting synonyms / or replace in terms query
- [ ] Add a fallback language for queries on certain fields (eg. product_name) corresponding to main product language
- [ ] Raise or at least warn if using an unknown field in a query (should catch labels_tasgs:en:fair-trade)
- [ ] labels_tags:"en:fair-trade" OR labels_tags:"en:eu-organic" should work (currently failing)
alexgarel commented 4 days ago

@raphael0202 this should be discussed to see what's best (next month)