Semantic Search
Using Miso’s deep learning semantic analysis, understand the intent and context behind a user’s query to return highly relevant search results
Introduction
Semantic Search lets Miso go beyond matching keywords - by understanding the intent and contextual meaning of a customer’s query. Trained on a corpus of 7 million e-commerce search phrases, Miso’s Search Engine will recognize product names, brand names, and even slang. It will know that chapstick is a type of lip balm and that a customer searching for rubbing alcohol is likely interested in first aid care, not vodka.
Examples
Enabling semantic search leads to increased product discovery, as comparable products may not have any keywords in common, but still be returned in the search results. Here are some examples:
A user searches for “la croix”. With keyword search, only products matching the keyword are returned. With semantic search, Miso’s Search Engine learns that La Croix is a type of sparkling water and returns similar products from other brands.
With semantic search, Miso’s Search Engine is able to return similar or complementary products like tortilla chips and salsa.
With keyword search, no matching products are found. With semantic search, Miso’s Search Engine is trained to recognize that “sick” is a synonym for illness and will return medicine or related products.
Do it with APIs
By default, Miso’s Search API returns products or content that match all keywords. With Partial Match, you can relax that criteria and return products that match some keywords. To return an even broader set of products that are related to the search terms, enable the semantic search parameter to have Miso’s Search Engine perform semantic analysis on the user’s query.
Let’s revisit our example of searching for the sparkling water brand “La Croix”, using both keyword search and semantic search.
Keyword Search Example
//Example Request
POST /v1/search/search
{
"q":"la croix",
"user_id":"user-123",
}
//Example Response
{
"data": {
"products": [
{"product_id": "LaCroix_Lime_8pk_12oz"},
"total": 1
}
}
When using keyword search, since there is only one “La Croix”-branded product in the catalog, only a single product will be returned by Miso’s Search API.
However, with semantic search, Miso’s Search Engine knows that La Croix is a brand of sparkling water and suggests additional similar products that would not have been recommended otherwise. Here’s how to enable semantic search:
Semantic Search Example
To enable semantic search within the Search API:
-
Set
enable_partial_match
totrue
. Semantic search is an extension of partial match (relaxing the constraint that returned products must match all keywords) so we must first enable partial match. -
Set
enable_semantic_search
totrue
. -
Choose from two partial match modes: blended (default) or separated.
- Blended: When
partial_match_mode
isblended
, keyword-matched items and semantically-matched items will be returned in the same, rank-sorted array. - Separated: When
partial_match_mode
isseparated
, keyword-matched items will be returned in aproducts
array and semantically-matched items will be returned in apartially_matched_products
array. A scenario where this is useful is if you only want to show semantically-matched products when the keyword-matched products are out of stock or not in your product catalog.
- Blended: When
-
If
partial_match_mode
is set toseparated
, you can optionally provide a value for the partial match threshold (enable_partial_match_threshold
). This parameter, which accepts aninteger
, informs Miso’s Search Engine when to provide partially matched results. For example, if we set"enable_partial_match_threshold" : 3
, partially matched results will only be returned when there are three or fewer exact keyword matches. By default, the partial match threshold is set to5
.
Example with Partial Match Mode - Blended:
//Example Request
POST /v1/search/search
{
"q":"la croix",
"user_id":"user-123",
"enable_partial_match" : true,
"enable_semantic_search" : true,
"partial_match_mode" : "blended"
}
//Example Response. All products are in the same array.
{
"data": {
"products": [
{"product_id": "LaCroix_Lime_8pk_12oz"},
{"product_id": "Waterloo_Peach_8pk_12oz"},
{"product_id": "Bubly_Cherry_8pk_12oz"}
],
"total": 3
}
}
Example with Partial Match - Separated:
//Example Request
POST /v1/search/search
{
"q":"la croix",
"user_id":"user-123",
"enable_partial_match" : true,
"enable_semantic_search" : true,
"partial_match_mode" : "seperated",
"enable_partial_match_threshold" : 5, //default value
}
//Example Response. Semantically-matched products are in a separate array.
{
"data": {
"products": [
{"product_id": "LaCroix_Lime_8pk_12oz"}
],
"partially_matched_products": [
{"product_id": "Waterloo_Peach_8pk_12oz"},
{"product_id": "Bubly_Cherry_8pk_12oz"}
]
}
}
Tips and Tricks
-
Before implementing semantic search via API, you can visually preview the results in Dojo. Open the Advanced Settings pane in the Search Engine Sandbox and toggle “enable_semantic_search” to ON to get started.
-
When using semantic search, look for the
_missing_keywords
field for each product in the response body. These are the keywords in the search query that were not found in the relevant product’s metadata. This information is often displayed on the search results page to improve the user experience. Here’s an example of a Google search for “la croix jackfruit”:
Additional Resources
For more information on Miso’s Search API, check out the official API Documentation.
For more recipes like this, visit the Recipes page on our Docs site.
Published Date: March 11th, 2022
API Reference
Need more info on the API? Check out our dedicated API page with all the info you could ever want.
Read API Reference