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

Example for Semantic Search

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:

semantic_search_lacroix.png

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.

semantic_search_guacamole.png

With semantic search, Miso’s Search Engine is able to return similar or complementary products like tortilla chips and salsa.

semantic_search_sick.png

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.

The following steps assume you have already set up an engine for Search. If not, head over to the Quickstart guide to get started.

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.

Partial match is required to enable semantic search. For more information on partial match, see the Partial Match Recipe .

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:

  1. Set enable_partial_match to true. 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.

  2. Set enable_semantic_search to true.

  3. Choose from two partial match modes: blended (default) or separated.

    • Blended: When partial_match_mode is blended, keyword-matched items and semantically-matched items will be returned in the same, rank-sorted array.
    • Separated: When partial_match_mode is separated, keyword-matched items will be returned in a products array and semantically-matched items will be returned in a partially_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.
  4. If partial_match_mode is set to separated, you can optionally provide a value for the partial match threshold (enable_partial_match_threshold). This parameter, which accepts an integer , 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 to 5.

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
Icon/Activity Icon/Add Icon/API Icon/Arrow/Down Icon/Arrow/Left Icon/Arrow/Right Icon/Arrow/TopRight Icon/Arrow/Up Icon/Bento Icon/Billing Icon/Bin Icon/Book Icon/Bookmark/Default Icon/Bookmark/Filled Icon/Calendar Icon/Caret/Down Icon/Caret/Up Icon/Chavron/DownIcon/Chavron/LeftIcon/Chavron/RightIcon/Chavron/UpIcon/Checknox/CheckedIcon/Checknox/Unchecked Icon/Checklist Icon/Chip Icon/Clipboard / Copied Icon/Clipboard/Default Icon/Clock/Stopwatch Icon/CMD Icon/Data/Catalog Icon/Data/Engine Icon/Data/Group Icon/Data/Interact Icon/Data/Users Icon/Dive Icon/Docs/Key Icon/Dojo Icon/Email Icon/Env/Development Icon/Env/Playground Icon/Env/Prod Icon/Folder Icon/Fullscreen/Collapse Icon/Fullscreen/Expand Icon/Guides/Multiple Icon/Guides/Single Icon/Hashtag Icon/Heart/Outline Icon/Heart/Solid Icon / Cart z Icon / Click Icon / Clock Icon / Data Icon / Doc Icon / EmptyCart z Icon/Social/Facebook Icon / Genome Incognito Icon / Money Icon/Social/ProductHunt Icon / Search Icon/Social/Twitter Icon / User Icon/Info/Error Icon/Info/Info Icon/Info/Question Icon/Info/Warning Icon/Interact/Download Icon/Interact/Edit Icon/Interact/External v2 Icon/Interact/External Icon/Interact/Filter Icon/Interact/Logout Icon/Interact/Options Icon/Interact/Re-order Icon/Interact/Reload Icon/Interact/Remove Icon/Interact/Replace Icon/Interact/Search Icon/Interact/Shuffle Icon/Interact/Undo Icon/Interact/Upload Icon/Interact/Video Icon/Invoice Icon/Loading Icon/Loading Icon/Lock/Locked Icon/Lock/Unlocked Icon/Lock Icon/Mapping Menu Icon/Notification Icon/Overview Icon/Person/Team Icon/Person/User Icon/Plan/Enterprise Icon/Plan/Growth Icon/Plan/Startup Icon/Plan/Trial Icon/Recipe Icon/Rocket Icon/Settings/App Icon/Settings/User Icon/Settings Icon/Shrine Icon/Sidebar/Close Icon/Sidebar/Open Icon/Slideout Icon/Sort/Ascending Icon/Sort/Default Icon/Sort/Descending Icon/Star/Filled Icon/Star/Outlined Stopwatch Icon/Support Icon/Tag Icon/Interact/Thumb/Dislike Icon/Interact/Thumb/Like Icon/Tick Icon/Trend/New Icon/Trend/Trending Icon/Tutorial Icon/Lock/Unlocked Icon/View/Grid Icon/View/List Icon/Watchlist/Add