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

feat: personal sort with demo #174

Closed alexgarel closed 1 week ago

alexgarel commented 1 week ago

A sort option for scripts + a demo in off.html

Part of: #172

alexgarel commented 1 week ago

I have 2 bugs when i try to test sort by personal score :

* second one, search return :
  `{ "debug": { "query": { "aggs": { "brands_tags": { "terms": { "field": "brands_tags" } }, "categories_tags": { "terms": { "field": "categories_tags" } }, "nutrition_grades": { "terms": { "field": "nutrition_grades" } }, "ecoscore_grade": { "terms": { "field": "ecoscore_grade" } } }, "sort": [ { "_script": { "type": "number", "script": { "id": "off__personal_score", "params": { "nutri_score": 1, "nova_group": 2, "eco_score": 0, "nova_to_score": [ 100, 100, 100, 75, 4 ], "grades_to_score": { "a": 100, "b": 75, "c": 50, "d": 25, "e": 0 } } }, "order": "desc" } } ], "size": 24, "from": 0 } }, "errors": [ { "title": "es_api_error", "description": "NotFoundError(404, 'search_phase_execution_exception', 'unable to find script [off__personal_score] in cluster state')" } ] }`

You have to run

docker compose run --rm api python -m app sync-scripts

(BTW I should add it to the deploy action)