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
10 stars 6 forks source link

Add support for sub fields of objects fields #237

Open alexgarel opened 3 months ago

alexgarel commented 3 months ago

Problem

Right now in search-a-licious, you can declare a field as an object, but there is no way you can specify the sub fields of those objects.

It can also lead to problem at import time. For example I got a float field (in nutrients), which was first interpreted as long (maybe because it was 0 in first elements)... in this case ES won't index some of the record because it can't change the field definition.

Proposed solution

Add a fields property to objects fields, that will works as the fields at the config level.

Also add a dynamic bool property to control the behaviour of ES dynamic property on the Object field.

Additional context

This might be needed if we want to handle nutrients correctly as numbers in Open Food Facts (and insure operators works correctly in rqeuests).

This should not be very difficult to implement:

alexgarel commented 3 months ago

I bumped priority because it can lead to dangerous pitfalls, as added in the comment. I loose time today because of this.