Grouping Multiple Collections for Federated Search
TLDR Kyle wanted to use federated search to group results from multiple collections. He was confused about how to selectively show tags in search context. Jason explained a way to achieve this by setting one filter for each tag and querying dynamically.
1
1
Jul 07, 2021 (31 months ago)
Kyle
06:44 PMKyle
06:44 PMlet searchRequests = {
'searches': [
{
'collection': 'movies',
'q': 'matrix',
'query_by': 'description'
},
{
'collection': 'user_tags',
'facetFilters': [ "tag:favorite"]
}
]
}
// Search parameters that are common to all searches go here
let commonSearchParams = {
'group_by': 'movie_id',
}
client.multiSearch.perform(searchRequests, commonSearchParams)
Jason
06:47 PMKyle
06:47 PMJason
06:51 PMJason
06:53 PM{
fields: [
...
{name: "userids_tagged_.*", type: "int32[]", optional: true}
]
}
Jason
06:55 PM{
description: "...",
userids_tagged_favorite: [1, 2, 3, 4],
userids_tagged_tagx: [1, 2, 10, 42],
}
Jason
06:59 PMKyle
06:59 PMKyle
07:00 PM1
Jason
07:00 PMJason
07:01 PMIf you filter on movies that only have that particular user's ID in any of the
userids_tagged_*
fields, that achieves this right?Kyle
08:26 PMuserids_tagged_tagx
, userids_tagged_tagy
but not userids_tagged_tagz
, how would the user see x
,y
available in the current search context but not z
?Jason
08:44 PM> how would the user see x,y available in the current search context but not z
Are users searching for both movie results and tag results? Or are they searching only for movie results from the movies that they've tagged?
Kyle
09:18 PMJul 08, 2021 (31 months ago)
Jason
12:31 AMSo if say a movie like this exists:
Jason
12:31 AM{
description: "...",
userids_tagged_favorite: [1, 2, 3, 4],
userids_tagged_tagx: [1, 2, 10, 42],
}
Jason
12:33 AM- the list of users who've tagged a movie with tag favorite
- the list of users who've tagged a movie with tag tagx
etc
Jason
12:37 AM[
{
collection: "movies",
q: "thriller",
query_by: "description",
filter_by: "userids_tagged_favorite:1"
},
{
collection: "movies",
q: "thriller",
query_by: "description",
filter_by: "userids_tagged_tagx:1"
},
{
collection: "movies",
q: "thriller",
query_by: "description",
filter_by: "userids_tagged_tagz:1"
},
// One query per tag - you'd have to maintain all the tags ever created on your side and use that to construct the query dynamically
]
Jason
12:40 AMuserids_tagged_tagz
, then the 3rd query above will return 0 results1
Kyle
04:07 PMTypesense
Indexed 3015 threads (79% resolved)
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.
Querying and Indexing Multiple Elements Issues
Krish queried fields with multiple elements, which Kishore Nallan suggested checking `drop_tokens_threshold`. Krish wished to force OR mode for token, but Kishore Nallan admitted the feature was missing. Krish was able to resolve the issue with url encoding.
Methods for Fetching, Querying, and Modifying Collections in Typesense
Bill inquired about performing OR queries, querying empty arrays and modifying collections in Typesense. Kishore Nallan explained the current limitations and provided workarounds and recommendations for each case. The conversation also touched upon the usage of cache in Typesense and the workings of the _eval function.
Querying with Not-in in Typesense
Masahiro inquired about using not-in queries in Typesense. Kishore Nallan explained how to conduct such queries by using the "-" operator in the query string, and assisted Masahiro with issues stemming from a high number of exclusion tokens. The problem was eventually resolved by switching to the `multi_search` endpoint.
Moving from Algolia to Typesense: Questions and Answers
Juan sought advice from Kishore Nallan about moving from Algolia to Typesense, handling MultiSearch, setting parameters, checking imported documents, and a specific syntax query.