#community-help

Customizing Search Query Results in Art Collection

TLDR John asked about customizing search results for an art collection. Jason recommended using Typesense's curation feature to create overrides for each category. Clarification about adding specific fields to a "category" document was also given.

Powered by Struct AI

3

1

11
30mo
Solved
Join the chat
Jun 04, 2021 (30 months ago)
John
Photo of md5-7a0ab48aa8979a59e1d8c3919797c1f8
John
11:30 PM
My daily question๐Ÿ˜ƒ: is it possible to customize part of the search query results, ignoring instantsearch.js/Typesense, adding some result(s) to the returned data? Let me give an example: my collection to be searched is a collection of arts, each one having various parameters that are queried (artnane, artcolor, etc.) and each one having one or several CATEGORIES. If I add the categories field to the query, the search results will return the products that are withing these categories and I do not want this. I would like to add a category 'card' to my displayed results, which when clicked will lead the user to the category page and list the category products from there... Is this a possibility?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
11:47 PM
Haha! Happy to answer questions.

Will this card you want to inject into the results be the same for all search results, or are you looking to essentially search for the query in the list of categories separately and display those as search results as well, in addition to the art work?
Jun 05, 2021 (30 months ago)
John
Photo of md5-7a0ab48aa8979a59e1d8c3919797c1f8
John
12:17 AM
I will be different from the main search results card - your second option
12:18
John
12:18 AM
What I would like is check if the query matches a category name, and if it does, inject this as the first card that will appear basically, with another template... Hmmm, seems complicated...
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
12:22 AM
Ah I see, you might be able to use the Curation feature: https://typesense.org/docs/0.20.0/api/curation.html

1

12:23
Jason
12:23 AM
Essentially, you'd want to add additional records to your collection, one for each category and have a field in each record to indicate that this is a special category record

1

12:24
Jason
12:24 AM
Then create an override for each category with a "contains" rule, so that if the query contains that category, it should pin that particular category record to position 1

1

John
Photo of md5-7a0ab48aa8979a59e1d8c3919797c1f8
John
05:02 PM
Looks like exactly what I was needing Jason, thank you!
06:16
John
06:16 PM
And here, just a confirmation please: there is no way I can add specific fields to such a "category" document -- I will need to fit with the fields I have defined in my schema collection, correct?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
06:41 PM
Correct. But you could may be have a type field which helps you determine if a record in the results is a category record or an art record

1

John
Photo of md5-7a0ab48aa8979a59e1d8c3919797c1f8
John
07:04 PM
Sure, OK, fine!