My daily question:smiley:: is it possible to custo...
# community-help
j
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?
j
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?
j
I will be different from the main search results card - your second option
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...
j
Ah I see, you might be able to use the Curation feature: https://typesense.org/docs/0.20.0/api/curation.html
👍 1
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
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
j
Looks like exactly what I was needing @Jason Bosco, thank you!
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?
j
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
j
Sure, OK, fine!