AutocompleteRequest

  • q
    Type: string · Q
    required

    The search query users typed so far. Please keep the trailing spaces (if any) intact so that we know whether the user has finished typing the last word or is still typing it. For example, the following query means the user has finished typing the word Fight:

    {"q": "Fight "}
    

    On the other hand, the following query means the user has not finished typing the last word Clu:

    {"q": "Fight Clu"}
    
  • additional_interactions
    Type: array · Additional Interactions

    A list of additional interaction records. You can use this fields to simulate user interactions without actually writing them to the interaction dataset.

      • type
        enum
        const:  
        product_detail_page_view
        required

        Used when a user views the detail page of a product. Viewing a product detail page usually indicates a user is interested in the product to certain degree, especially, when the duration of the page view is long. When duration of the page view is very short (< 5 seconds), product_detail_page_view may indicate neural or negative interest in the product.

        values
        • product_detail_page_view
      • anonymous_id
        Type: string · Anonymous Id
        max length:  
        1024

        A pseudo-unique substitute for the User Id. We use anonymous_id to identify a visitor who has not signed in. anonymous_id can be implemented using mechanisms such as cookies or browser localStorage. If anonymous_id is not given, we will default it to SHA1(<API key>:<IP address>:<user agent>:<date>). When a visitor signs in and the user_id and anonymous_id are both present, the anonymous_id will be linked to the user_id along with the past interactions associated with it.

      • context
        Type: object · Context

        Dictionary of extra information that provides useful context about an interaction. We use context information to make recommendations tailored not only for each user, but also for their current browsing context. For example, a user browsing on a desktop may have different browsing behavior than a user browsing on mobile phone. As another example, a user who gets to the site via a certain campaign you run on Facebook may have very different interests than a user who visits your site directly.

        Context information is also useful for personalization for entirely new visitors, as we can immediately personalize their experiences based on their context alone (e.g. the referrer or the campaign they clicked through).

        Example:

        {"context": {
            "campaign":
            {
                "name": "spring_sale",
                "source": "Google",
                "medium": "cpc",
                "term": "running+shoes",
                "content": "textlink"
            },
            "truncated_ip": "1.1.1.0",
            "locale": "en-US",
            "region": "US East",
            "page":
                {
                    "url": "https://example.com/miso-tshirt-123ABC",
                    "referrer": "https://example.com/",
                    "title": "My Product Page"
                },
                "user_agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0)"
            },
            "custom_context": {
                "other_context_var_1": "value_1",
                "other_context_var_2": "value_2"
            }
        }
        
      • duration
        Type: number · Duration

        How long (in seconds) the user stayed on this page, or consumed (listened, read, or watched) a product. This field is optional, but it's very important in scenarios where consumption duration matters, including product_detail_page_view, category_page_view, watch, listen, and read. For example, if a user only views or consumes a product for less than 5 seconds, that user is probably not interested in the product. On the other hand, if a user stays on a page for a while, it usually means they are seriously engaging with or considering the product. When duration is absent, we will use the timestamp of the next interaction to infer a rough duration value.

        Example:

        {"duration": 61.5}
        
      • miso_id
        Type: string · Miso IdFormat: uuid

        Miso-generated unique Id for each recommendation or search result. Maintaining this Id for subsequent page views is important to Miso's performance, as we use miso_id to track and fine-tune the performance of personalization and search results. When a user clicks on a recommendation or search result, you should pass the associated miso_id to the next page view, and associate the miso_id with the interactions that take place on the page (e.g. product_detail_page_view, add_to_cart, add_to_collection, like, etc.). In this way, Miso will learn which recommendations work and which didn't.

        Example:

        {"misoId": "123e4567-e89b-12d3-a456-426614174000"}
        
      • product_group_ids
        Type: array string[] · Product Group Ids
        max length:  
        512

        The product groups the user is interacting with. You only need this field if you model product variants using product_id and product_group_id (see Product API). If so, you should use this field, when a user is interacting with a product group rather than a specific product variant, for example, when the user is viewing the master page of a T-shirt (i.e. a product group), but has not selected the specific size or color (i.e. a product variant) yet.

        In such situations, the product_id is not applicable because we only know the user is interested in this T-shirt (a product group), but don't know which particular product variant the user is interested in. Therefore, we use product_group_ids to capture such interactions in place of product_ids.

        In the situations where specific product_ids are available, for example, when user selected a particular size of the T-Shirt, use product_ids instead.

        Example:

        {"product_group_ids": ["123ABC"]}
        
      • product_ids
        Type: array string[] · Product Ids
        max length:  
        512

        Products or content the user is interacting with. This field is required by almost all the interaction types. We use product_ids to refer to the product / content records that you upload to Miso. Therefore, it is important to keep this consistent between the two datasets.

        Example:

        {"product_ids": ["123ABC-BLACK", "123EFG-YELLOW"]}
        
      • timestamp
        Type: string · TimestampFormat: date-time

        The ISO-8601 timestamp specifying when the interaction occurred. If the interaction just happened, leave it out and we will default to the server's time. If you're importing data from the past, make sure you provide a timestamp. It is recommended to include milliseconds in the timestamp to provide a higher time resolution.

        Example:

        {"timestamp": "2018-11-07T00:25:00.073876Z"}
        
      • user_id
        Type: string · User Id
        max length:  
        512

        Identifies the signed-in user who performed the interaction. We will use user_id to link Interaction records to your User records. Therefore, it is important to keep this consistent between the two datasets.For visitors who have not signed in, see anonymous_id.

  • anonymous_id
    Type: string · Anonymous Id

    The anonymous visitor who made the query and for whom Miso will personalize the results. Either user_id or anonymous_id needs to be specified for personalization to work.

  • boost_fq
    Type: string · Boost Fq

    Defines a query in Elasticsearch query-string syntax (Lucene) that can be used to boost a subset of products to the top of the ranking, or to specific boost positions (See boost_positions parameter below.) For example, the query below will promote all the relevant products whose brand is Nike to the top of recommendation list:

    {
        "boost_fq": "brand:\"Nike\""
    }
    

    For a slightly more complex example, the query below will promote the Nike products which have also been tagged as ON SALE to the top of the ranking:

    {
       "boost_fq": "brand:\"Nike\" AND tags:\"ON SALE\""
    }
    

    It is worth mentioning that, Miso will only boost products that are relevant and have high likelihood to convert, and will not boost a low performance product only because it matches the boosting query.

    Depending on your boosting rules, in certain cases, you would like to prevent recommendation results from being too monotone due to boosting. With Miso, you have two tools to do so.

    First, you can specify boost_positions to place promoted products at specific positions in the ranking. For example, the query below will place boosted products only at the first and fourth places in the ranking (positions are 0-based), and place the remaining products in their original ranking, skipping these two positions.

    {
       "boost_fq": "brand:\"Nike\" AND tags:\"ON SALE\"",
       "boost_positions": [0, 3]
    }
    

    The second tool is diversification. diversification parameter, on a best-effort basis, will try to maintain a minimum distance between products that have the same attributes. For example, the following query will place products made by the same brand apart from each other.

    {
       "boost_fq": "brand:\"Nike\" AND tags:\"ON SALE\"",
       "diversification": {
           "brand": {"minimum_distance": 1}
        }
    }
    
  • boost_positions
    Type: array integer[] · Boost Positions

    Defines a list of 0-based positions you want to place the boosted products at.

    For example, the query below will promote products whose brand is Nike as the top and second recommendations:

    {
        "boost_fq": "brand:\"Nike\"",
        "boost_positions": [0, 1]
    }
    

    If boost_positions is not specified (which is the default behavior), all the boosted products will be ranked higher than the rest of the products.

  • boost_rule_name
    Type: string · Boost Rule Name

    Name of the boosting rule. Use this to identify a boosting rule in _boosted_rules in the response

  • boost_rules
    Type: array object[] · Boost Rules

    Define a list of boosting rules that will be applied to the search or recommendation results simultaneously. boost_rules parameter is particularly useful when you want to boost more than one sets of products, and promote each of them to different positions. For example, the query below will promote products whose brand is Nike to the top and second results, and products whose brand is Adidas to the third and fourth results:

    {
        "boost_rules": [
            {
                "boost_fq": "brand:\"Nike\"",
                "boost_positions": [0, 1]
            },
            {
                "boost_fq": "brand:\"Adidas\"",
                "boost_positions": [2, 3]
            }
        ]
    }
    
    • boost_fq
      Type: string · Boost Fq

      Defines a query in Elasticsearch query-string syntax (Lucene) that can be used to boost a subset of products to the top of the ranking, or to specific boost positions (See boost_positions parameter below.) For example, the query below will promote all the relevant products whose brand is Nike to the top of recommendation list:

      {
          "boost_fq": "brand:\"Nike\""
      }
      

      For a slightly more complex example, the query below will promote the Nike products which have also been tagged as ON SALE to the top of the ranking:

      {
         "boost_fq": "brand:\"Nike\" AND tags:\"ON SALE\""
      }
      

      It is worth mentioning that, Miso will only boost products that are relevant and have high likelihood to convert, and will not boost a low performance product only because it matches the boosting query.

      Depending on your boosting rules, in certain cases, you would like to prevent recommendation results from being too monotone due to boosting. With Miso, you have two tools to do so.

      First, you can specify boost_positions to place promoted products at specific positions in the ranking. For example, the query below will place boosted products only at the first and fourth places in the ranking (positions are 0-based), and place the remaining products in their original ranking, skipping these two positions.

      {
         "boost_fq": "brand:\"Nike\" AND tags:\"ON SALE\"",
         "boost_positions": [0, 3]
      }
      

      The second tool is diversification. diversification parameter, on a best-effort basis, will try to maintain a minimum distance between products that have the same attributes. For example, the following query will place products made by the same brand apart from each other.

      {
         "boost_fq": "brand:\"Nike\" AND tags:\"ON SALE\"",
         "diversification": {
             "brand": {"minimum_distance": 1}
          }
      }
      
    • boost_positions
      Type: array integer[] · Boost Positions

      Defines a list of 0-based positions you want to place the boosted products at.

      For example, the query below will promote products whose brand is Nike as the top and second recommendations:

      {
          "boost_fq": "brand:\"Nike\"",
          "boost_positions": [0, 1]
      }
      

      If boost_positions is not specified (which is the default behavior), all the boosted products will be ranked higher than the rest of the products.

    • boost_rule_name
      Type: string · Boost Rule Name

      Name of the boosting rule. Use this to identify a boosting rule in _boosted_rules in the response

  • completion_fields
    Type: array string[] · Completion Fields

    Controls the sources of autocompletion candidates. Miso performs autocompletion by matching what the user has typed so far to either the title of products or to other attributes.

    By default, we only autocomplete against the value in the title field. The completion_fields parameter lets you specify the attributes you want to perform autocompletion against. For example, the following query will limit the autocompletion candidates to the title and tags of products:

    {"completion_fields": ["title", "tags"]}
    

    Autocompletion also works on custom attributes. For example, if you have a custom attribute for the designer_name of the product, the following query limits autocompletion candidates to only the designer names:

    {"candidates": ["custom_attributes.designer_name"]}
    
  • dedupe_product_group_id
    Type: boolean · Dedupe Product Group Id

    Whether to dedupe product based on product_group_id. If dedupe_product_group_id=true, Miso will prevent products with the same product_group_id from showing multiple times in the search or recommendation results.

    This is particular useful when one product has multiple variants (for example, different sizes, colors, or materials), and you only want to show this product only once in the search or recommendation results. Miso will then return the variant that is most likely to be of the user's interest.

  • engine_id
    Type: string · Engine Id

    The engine you want to get results from. When you have more than one engine, you can use this parameter to specify the specific engine you want to get results from. If not specified, the default engine will be used.

  • fl
    Type: array string[] · Fl

    List of fields to retrieve. For example, the following request retrieves only the title field of each product along with the product_id, which is always returned.

    {"fl": ["title"]}
    

    You can also match field names by using * as a wildcard. For example, the query below retrieves the title and any custom attributes under the attributes dictionary.

    {"fl": ["title", "attributes.*"]}
    

    The following retrieves all the available fields:

    {"fl": ["*"]}
    

    For the lowest latency, use an empty array to retrieve just the product_id field (which is the default).

    {"fl": []}
    
  • fq
    Type: string · Fq

    Defines a query in Elasticsearch query-string syntax (Lucene) that can be used to restrict the superset of products to return, without influencing the overall ranking. fq can enable users to drill down to products with specific features based on different product attributes

    For example, the query below limits the search results to only show products whose size is either M or S and brand is Nike:

    {"fq": "size:(\"M\" OR \"S\") AND brand:\"Nike\""}
    

    You can use fq to apply filters against your custom attributes as well. For example, the query below limits the search results to only products whose designer attribute is Calvin Klein

    {"fq": "attributes.designer:\"Calvin Klein\""}
    

    fq can also limit search results by numerical range. For example, the following query limits the results to products that have rating >= 4.

    {"fq": "rating:[4 TO *]"}
    
  • geo
    Type: object · Geo

    When set, filter result to include only products within certain geographic range from given point will be returned, or to boost product within the same range.

    Product should have a field that holds the location of the product, location is used by default, but other field can also be used.

    Distance can be in miles or kilometers. If distance_unit is not set, mile will be used.

    For example, to limit results to products within 100 miles of New York city:

    {
        "geo": {
            "filter": [{
                "lat": 40.73061,
                "lon": -73.93524,
                "distance": 100
            }]
        }
    }
    

    To boost products within 2 kilometers around Alcatraz Island according to loc field:

    {
        "geo": {
            "boost": [{
                "field": "loc",
                "lat": 37.82667,
                "lon": -122.42278,
                "distance": 2,
                "distance_unit": "km"
            }]
        }
    }
    
    • boost
      Type: array object[] · Boost

      When set, boost products within certain geographic range from given point.

    • filter
      Type: array object[] · Filter

      When set, filter result to include only products within certain geographic range from given point.

  • language
    Type: string · Language

    Two-letter (639-1) language code of the search query. If given, the autocomplete results will be from that specific language. If not given, the autocomplete results will be from the primary language of the environment. Example query:

    {"language": "en"}
    
  • min_query_users
    Type: integer · Min Query Users

    Limits the query completion results to historical queries that have been made by at least this number of unique users. This parameter has no effect when completion_fields does not include historical_queries. We do not recommend setting min_query_users lower than 5. When min_query_users is too small, we might risk showing queries that contain typos or are too personal to the users who made the query.

  • rows
    Type: integer · Rows

    Number of search results to return.

  • type
    Type: string · Type

    The type of products to return. Use this parameter to make the API return only a certain type of products (see Product APIs).

    This is particularly useful for sites that have multiple types of products: For example, on a marketplace site, YOu may model merchandise and store as two types of products. You can then use type parameter to limit the recommendation or search results to return only one kind of them.

    For instance, the following query will return only store products:

    {"type": "store"}
    

    For another example, on a travel website, you might have: hotel, thing to do, and restaurant, three kinds of products. You can use type parameter to limit results to one kind of them. For instance, the following query will limit the results to only hotels product:

    {"type": "hotel"}
    
  • user_cohort
    Type: object · User Cohort

    The user cohort you want to cold-start the recommendation with. For example, the following query will make recommendations based on the preferences of the users whose country="United States", and gender="Female" in the User Profile dataset.

    {
        "user_cohort": {
            "country": "United States",
            "gender": "Female"
        }
    }
    
    • propertyName
      • Type: boolean
  • user_hash
    Type: string · User Hash

    The hash of user_id (or anonymous_id) encrypted by your Secret API Key. user_hash is required to prevent unauthorized API access if you are making API calls with a Publishable API Key.

    You should generate the user_hash via HMAC scheme: you encrypt the desired user_id (or anonymous_id) with your Secret API Key on your backend server, and then let the front-end code send the generated user_hash to Miso APIs to verify the identity of the API caller.

    As long as the Secret API Key is kept secret, the user_hash prevents a malicious attacker from making unauthorized API calls or impersonating any of your users.

    Miso APIs accept the case-incentive "hex digest" of user hash, a sample Python 3 code to generate it on your backend server is as follow:

    import hashlib
    import hmac
    
    YOUR_MISO_SECRET_API_KEY = "039c501ac8dfcac91"
    key_bytes = YOUR_MISO_SECRET_API_KEY.encode()
    user_id = "USER_123" # or anonymous_id
    user_id_bytes = user_id.encode()
    user_hash = hmac.new(
        key_bytes,
        user_id_bytes,
        hashlib.sha256).hexdigest()
    # user_hash is "7eb04da5e..."
    

    You can find more examples for other languages in this Github Gist

  • user_id
    Type: string · User Id

    The user who made the query and for whom Miso will personalize the results. For an anonymous visitor, use anonymous_id instead.