Discussing Implementation of Nested Fields Feature
TLDR Stefan asks about modeling ingredients data in a database, but realizes it might reference too much for the search engine. Kishore Nallan confirms his query is IN search-related and mentions plans to support nested fields in later updates.
1
Feb 12, 2022 (21 months ago)
Stefan
12:25 PMAm I correct that there is currently no way to cover a use case like this:
Assuming I have a database of meals where each meal has X ingredients.
Each ingredient is present in a certain amount
In a perfect world I would model it like this:
ingredients: [
{
name: "chicken",
concentration: num
}
]
And then filter for it like this:
ingredients.name = 'chicken' AND ingredients.concentration >= 5
Where ingredients should refer to the same nested Object
While writing this I realized that this is probably way too much for typesense or any search engine to cover. This is something for a database. Asking it anyway just in case I am missing something.
Only idea I have to cover this use case is to go crazy and flatten the ingredients array like this:
chicken.present: bool
chicken.concentration: num
But given that there can be thousands of ingredients this would probably not scale well.
Stefan
12:26 PMKishore Nallan
12:32 PMThe other way to solve this is with a join, which we are also exploring. In that case you will have a separate ingredients collection that has a reference id to the main recipe collection such that it will be trivial to filter on the ingredients and then join on the other fields from the recipe collection.
Kishore Nallan
12:33 PMStefan
12:33 PMStefan
12:35 PMKishore Nallan
12:38 PMStefan
12:41 PM1
Typesense
Indexed 2779 threads (79% resolved)
Similar Threads
Handling Nested Objects in Typesense
Darren queried about storing arrays of objects in Typesense. Kishore Nallan advised that Typesense doesn't support nesting but shared alternative reindexing methods. They added improved nesting support is planned for the future.
Discussions on Typesense, Collections, and Dynamic Fields
Tugay shares plans to use Typesense for their SaaS platform and asks about collection sizes and sharding. Jason clarifies Typesense's capabilities and shares a beta feature. They discuss using unique collections per customer and new improvements. Kishore Nallan and Gabe comment on threading and data protection respectively.
Issues Sorting Multiple Fields with Sort_by in Typesense Query
Rishabh was having trouble sorting two fields separately with a single query. Jason explained that a secondary sorting will only occur if the first sort results in matching values. They clarified the functionality of sorting in various search engines.
Issue with Sorting Search Request
Anton encounters an issue with sorting a search request due to an assuredly existing field appearing absent. Jason complements by revealing string sorting isn't supported. Kishore Nallan confirms future support for string sorting, despite its memory-demands.
Discussing Support for Nested Objects in Typesense
Martin expressed the need for support for nested objects in Typesense. Kishore Nallan mentioned the possibility of flattening objects before indexing and restoring them later. An issue has been created on GitHub to track this.