Let's say I have a product catalog index like below, where I have a list of products that have an array of individual sku child objects. I want to be able to perform a search that returns the matching product documents, but also indicate the relevancy of the child sku elements (or sort them, or something).
{
"productId": "1",
"name": "Cool Shirt",
"type": "t-shirt",
"skus": [
{
"skuNumber": "1-a",
"color": "green",
"image": "..."
},
{
"skuNumber": "1-b",
"color": "red",
"image": "..."
}
]
},
{
...additional documents
}
A search for red t-shirt should return this document, but I'd like to know that the second sku (color:red) was more relevant than the first sku - maybe by having a relevancy score applied to these child objects, or having Azure sort them accordingly. The goal is to be able to present a search result to a user as a product tile that highlights the most relevant child sku - in this case by displaying this "Cool Shirt" product with the red shirt sku's image.
Real world example of this in practice:
Search https://www.amazon.com/s?k=Hanes+Unisex+T-Shirt+red and the top result is the red "sku" of the product, search https://www.amazon.com/s?k=Hanes+Unisex+T-Shirt+green and you'll see the green "sku".
Are there any techniques to accomplish this with Azure Cognitive Search?
The investigation my team has done so far has not yielded good results. We're migrating from a Solr search implementation where this is accomplished a bit differently - by indexing the individual skus and then grouping them by a parent id. Newer versions of Solr suggest this approach https://solr.apache.org/guide/6_6/collapse-and-expand-results.html. My understanding is that Azure search does not support these capabilities.
Our workaround
The most promising option we've come up with is to have two indexes. One of the products (same as above) and another of just the skus, like so:
{
"productId": "1",
"skuNumber": "1-a",
"color": "green",
"image": "..."
},
{
"productId": "1",
"skuNumber": "1-b",
"color": "red",
"image": "..."
}
We'd first perform a search to get a list of relevant products, and then follow-up with an identical search to the sku index filtered only by skus with a parent product id from first result red t-shirt $filter productId eq '1' ...etc for all product ids returned by the first search. The relevancy score of this second search would then allow us to rank the child skus as I am describing. But this seems far from an ideal solution. Any other options?
Notes
Please note:
- I'm willing to restructure our Index(s) in any way feasible
- There will be dozens of additional fields at the sku level beyond just "color"
- We don't want less/non-relevant skus to be completely filtered out; for
red t-shirtwe still want to display a product tile that indicates there's a green version too, for instance - Relevancy of skus would need work for filtering and faceting, in addition to text search. Eg.
red t-shirt, filter=inStock ,facet=price[$5-$10]would need to surface the sku that most closely matched this criteria - We'll be using traditional paging of results (as opposed to infinite-scroll)