Consolidating Multiple Collection Queries in Typesense
TLDR Cooper asked about consolidating queries from multiple collections, while Jason suggested client-side aggregation. Cooper ended up using nested objects to achieve the desired result.
1
Mar 21, 2023 (7 months ago)
Cooper
08:17 PMI am looking at using the federated search feature and noticed that the hits when using multiple collections are returned as an array of arrays, one for each index that is being queried. For my application i hope to consolidate querying multiple indices into a single flattened list with correct scoring. Is this a possibility?
The difficulty I'm getting is from using the
TypesenseInstantSearchAdapter
, where I have to use individual <Index />
components for each collection that I want to query. The example UI from the docs has the returned lists in side-by-side components, whereas I would like a single list (<Hits />
component) with results from both collections, still sorted by score.I'm new to Typesense and am loving it so far! Very easy to get going with and is really well documented with lots of examples 💃 🙂 Thanks!
1
Jason
09:09 PMCooper
09:13 PMThis makes sense, I think the route I will go is to use nested objects to achieve the same behaviour, and then just using the dot notation to query different object types on a single collection. I tried this and it works nicely via the API.
Jason
09:14 PMTypesense
Indexed 2786 threads (79% resolved)
Similar Threads
Multi-Index Search with Typesense Instantsearch Adapter
Ailish needed help with multi-index search using the Typesense instantsearch adapter. Kishore Nallan explained the server API separates these search requests, but can be merged using business logic. Jason suggested building custom widgets to do a multi-search request and aggregate scores on the client side.
Resolving Issues with 'React-InstantSearch'
robert was having trouble merging results from different collections using `react-instantsearch` and was facing issues with undefined highlight results. After much discussion, Jason provided a solution using `collectionSpecificSearchParameters` and `highlight_full_fields` to solve the problem.
Connecting Multiple Instances of TypesenseInstantsearchAdapter
sonu questioned on connecting typesenseInstantsearchAdapter to different collections. Jason directed them to the pre-release version and suggested how to create a federated search with Instantsearch components.