#community-help

Including All Individual Documents in a Group in Typesense

TLDR Magnus was uncertain how to include all documents within a group in Typesense, and specifically asked about ecommerce product cards. Jason published a new version of Typesense Instantsearch Adapter and advised storing all variant information for a product on each document. Magnus confirmed this as a viable solution.

Powered by Struct AI
Jun 29, 2022 (18 months ago)
Magnus
Photo of md5-7d2796ababc14477f4c09abc2e8edb05
Magnus
06:44 PM
Hi again. Having a lot of fun with Typesense.

I am playing with group_by and group_limit. I can see the structure for a grouped document is slightly different but was then wondering, if there’s a way to include all of the individual documents that is contained in a group. I know that might sound counter intuitive but would be useful in a case, where you want to show information from the grouped documents. The specific case is this product cards on an ecommerce site. Here’s a screenshot that maybe explains it better:
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
06:48 PM
Setting group_limit to a large number (even as high as say 10,000) assuming that's the max number of variations you can have in a product, should work...
Jun 30, 2022 (18 months ago)
Magnus
Photo of md5-7d2796ababc14477f4c09abc2e8edb05
Magnus
09:29 AM
Thank you Jason. I think I get the point, however, I am uncertain whether this can work with Instantsearch.js (React Instantsearch Hooks), as it seems to treat grouped document separately.

See pictures, for how it currently looks and the response result.

Instantsearch.js seems to have a distinct configure option but can that work with the typesense adapter — not sure if it’s at all relevant?

I’ve attempted to transform the hits but the hit results does not contain data about the group.

How would I go about combining them into a single ‘hit’ for Instantsearch?

Thank you 🙂
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
05:16 PM
> I’ve attempted to transform the hits but the hit results does not contain data about the group.
I was going to suggest this... but the adapter doesn't add this group information currently. Let me add this and give you a version to test
06:33
Jason
06:33 PM
Just published v2.4.2-0 of typesense-instantsearch-adapter, which will now add a group_key field to each hit. So you should be able to use that to group using transformHits
06:33
Jason
06:33 PM
Could you give it a shot and let me know how it goes?
Jul 01, 2022 (18 months ago)
Magnus
Photo of md5-7d2796ababc14477f4c09abc2e8edb05
Magnus
06:33 AM
I’ll give it shot and report back 🙂
10:29
Magnus
10:29 AM
Working great Jason 👍 Thank you.

I might have run into other troubles that I hadn’t thought about. But I’ll report back when I have more information 🙂

Anyhow, I might have to index variant information on every document. My current issue is, that I want to show shoe size availability and color variant on a single hit/model (product card). But with grouping I am not certain to get every document belonging to that group obviously. Eg. if I query “nike free blue”, I will only get the documents for the blue variant and not the red variant, even though I want to show that as well.

I haven’t explored the issue thoroughly yet. But if you have any ideas they’re more than welcome 😉
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
03:54 PM
Storing all variants information for a product on each variant document (as unindexed fields) might be the way to go

Typesense

Lightning-fast, open source search engine for everyone | Knowledge Base powered by Struct.AI

Indexed 3015 threads (79% resolved)

Join Our Community

Similar Threads

User-Specific Tagging and Filtering in UI

bnfd asked for the best way to create user-specific tags available on the UI. Jason suggested using personalized filters and creating a separate collection for each user's movies. The duo clarified the use of 'tags' in schemas and the refinementList widget in instantsearch. They also discussed various approaches to import and search large document collections.

1

46
29mo

Cold Start Problem with Dynamic Collections

Adrian reported cold start issues with dynamic collections. Jason suggested using wildcard `*` for query_by parameters, upgrading to `0.25.0.rc34`, and clarified conventions. Adrian's issues were resolved but they reported a limitation that will potentially be addressed.

6

39
6mo

Ecommerce Search Engine with User-added Products

Max seeks advice on handling a boolean field showing if a product is already in a user's cart for an ecommerce search engine. Kishore Nallan suggests waiting for the future "join" feature to allow merging separate indexes at query time.

3

9
8mo

Implementing Histogram Slider with Typesense

em1nos asked about implementing a histogram slider with typesense. James suggested using facets and group by feature. Jason recommended creating a new field for price buckets to achieve the desired output using facet_counts.

1

41
10mo

Understanding and Implementing Typesense Dart Library with Flutter

Alexandro sought help with the Typesense Dart library. Jason explained that the library is in progress, discussed utilizing other HTTP libraries, and provided detailed instructions on utilizing Typesense with Flutter. Alexandro provided feedback on the Typesense UI and expressed interest in creating a tutorial video.

10

82
32mo