Hussain Sakariya
08/28/2025, 7:31 AMI am searching for products in Typesense using title or variants.title, and it works fine.
Each product has multiple variants stored as an array.
My requirement is: when a user searches for a term, the best-matching variant should be placed first in the variants array in the search response (because by default we show the first variant's data).
Example:
product_data = {
"id": "1",
"title": "shirt",
"variants": [
{ "title": "red", "image": "1.png" },
{ "title": "blue", "image": "2.png" },
{ "title": "green", "image": "3.png" }
]
}
Search term: "green shirt"
// Required response from Typesense:
response = {
"id": "1",
"title": "shirt",
"variants": [
{ "title": "green", "image": "3.png" },
{ "title": "red", "image": "1.png" },
{ "title": "blue", "image": "2.png" }
]
}
In short, I want the matched variant to be reordered to the top of the variants array in the Typesense search result.
Please suggest if there is another way to achieve the same things.
Hussain Sakariya
08/28/2025, 10:24 AMAlan Martini
08/28/2025, 3:41 PMHussain Sakariya
08/29/2025, 9:10 AMHussain Sakariya
09/01/2025, 9:14 AMFanis Tharropoulos
09/01/2025, 9:16 AMHussain Sakariya
09/01/2025, 9:21 AMKishore Nallan
09/01/2025, 9:23 AMHussain Sakariya
09/01/2025, 9:24 AM