SearchRequest
- additionalType: array · Additional Interactions
_interactions A list of additional interaction records. You can use this fields to simulate user interactions without actually writing them to the interaction dataset.
- typeenumconst:product_detail_page_viewrequired
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
durationof the page view is long. Whendurationof the page view is very short (< 5 seconds),product_detail_page_viewmay indicate neural or negative interest in the product.values- product
_detail _page _view
- anonymousType: string · Anonymous Id
_id max length:1024A pseudo-unique substitute for the User Id. We use
anonymous_idto identify a visitor who has not signed in.anonymous_idcan be implemented using mechanisms such as cookies or browser localStorage. Ifanonymous_idis not given, we will default it toSHA1(<API key>:<IP address>:<user agent>:<date>). When a visitor signs in and theuser_idandanonymous_idare both present, theanonymous_idwill be linked to theuser_idalong with the past interactions associated with it. - contextType: 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" } } - durationType: 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, andread. 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. Whendurationis absent, we will use the timestamp of the next interaction to infer a rough duration value.Example:
{"duration": 61.5} - misoType: string · Miso IdFormat: uuid
_id 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_idto 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 associatedmiso_idto the next page view, and associate themiso_idwith 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"} - productType: array string[] · Product Group Ids
_group _ids max length:512The product groups the user is interacting with. You only need this field if you model product variants using
product_idandproduct_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_idis 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 useproduct_group_idsto capture such interactions in place ofproduct_ids.In the situations where specific
product_idsare available, for example, when user selected a particular size of the T-Shirt, useproduct_idsinstead.Example:
{"product_group_ids": ["123ABC"]} - productType: array string[] · Product Ids
_ids max length:512Products or content the user is interacting with. This field is required by almost all the interaction types. We use
product_idsto 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"]} - timestampType: 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"} - userType: string · User Id
_id max length:512Identifies the signed-in user who performed the interaction. We will use
user_idto 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, seeanonymous_id.
- advancedType: string · Advanced Q
_q min length:1Like Google's Advanced Search, the
advanced_qparameter let you define query beyond simple full-text search. For one, you can use double-quotes to indicate a phrase search.For example, the following query will only match Products that contain the phrase "Toy Story 4", and will not match Products like "4 Toy Story" (because the word order is not the same as the given query).
{"advanced_q": "full_text:\"Toy Story 4\""}If you don't want phrase search, you can enclose the search terms with parenthesis to indicate regular full-text query. For example:
{"advanced_q": "full_text:(Toy Story 4)"}You can also use AND/OR boolean operators to combine multiple full-text queries. For example, the following query will match Products with phrases "Toy Story 4" and Products with phrases "Toy Story 3", and will not match "Toy Story 2" or "Toy Story 1":
{"advanced_q": "full_text:\"Toy Story 4\" OR full_text:\"Toy Story 3\""}Finally, you can use AND/OR boolean operators to combine full-text search with metadata filtering. For example, the following example will find Products with phrase "Toy Story" OR Products which have Tom Hanks as an actor.
{"advanced_q": "full_text:\"Toy Story\" OR custom_attributes.actors:\"Tom Hanks\""}(to make a search request, You need to specify either
qoradvanced_q) - anchoringType: array object[] · Anchoring Settings
_settings Promote a product to a position relative to the highest-ranked anchor product.
A common use-case is promoting a private-label good by anchoring it to a name-brand counterpart. When the name-brand good (the anchor) appears in a search result, the private-label good also appears in the result (at a specified distance from the anchor product).
The
anchoring_settingsobject has the following fields:- product_id - The
product_idof the product you want to promote. - anchor_ids - The array of
product_idsthat act as the anchors. - relative_position (optional) - The position that the promoted product will be returned in the search results, relative to the highest-ranked anchor product. For example, setting this parameter to
1will place the promoted product directly after the anchor product. The default value is-1, which will place the promoted product directly before the anchor product. - start_time (optional) - An ISO-8601 timestamp indicating when to start the product anchoring. Ex:
2022-01-29T00:00:00Z - end_time (optional) - An ISO-8601 timestamp indicating when to end the product anchoring. Ex:
2022-05-31T23:59:59Z
For example, if a user searches for "cookies", the API request might look like this:
POST v1/search/search { "q":"cookies", "anchoring_settings": [ { "product_id": "private_label_cookies", "anchor_ids": [ "name_brand_cookies_1", "name_brand_cookies_2" ], "relative_position": -1, "start_time": "2022-01-01T00:00:00Z", "end_time": "2022-12-31T23:59:59Z" } } ] }- anchorType: array string[] · Anchor Ids
_ids min length:1requiredA list of anchor products
- productType: string · Product Id
_id requiredProduct to boost
- endType: string · End TimeFormat: date-time
_time When will the anchoring end. Leave it unset to not have an end time
- relativeType: integer · Relative Position
_position Relative position to the top anchor product
- startType: string · Start TimeFormat: date-time
_time When does the anchoring start. Leave it unset to start immediately
- product_id - The
- anonymousType: string · Anonymous Id
_id The anonymous visitor who made the query and for whom Miso will personalize the results. Either
user_idoranonymous_idneeds to be specified for personalization to work. - boostType: string · Boost Fq
_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_positionsparameter below.) For example, the query below will promote all the relevant products whose brand isNiketo 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 SALEto 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_positionsto 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.diversificationparameter, 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} } } - boostType: array integer[] · Boost Positions
_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
Nikeas the top and second recommendations:{ "boost_fq": "brand:\"Nike\"", "boost_positions": [0, 1] }If
boost_positionsis not specified (which is the default behavior), all the boosted products will be ranked higher than the rest of the products. - boostType: string · Boost Rule Name
_rule _name Name of the boosting rule. Use this to identify a boosting rule in _boosted_rules in the response
- boostType: array object[] · Boost Rules
_rules Define a list of boosting rules that will be applied to the search or recommendation results simultaneously.
boost_rulesparameter 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 isNiketo the top and second results, and products whose brand isAdidasto the third and fourth results:{ "boost_rules": [ { "boost_fq": "brand:\"Nike\"", "boost_positions": [0, 1] }, { "boost_fq": "brand:\"Adidas\"", "boost_positions": [2, 3] } ] }- boostType: string · Boost Fq
_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_positionsparameter below.) For example, the query below will promote all the relevant products whose brand isNiketo 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 SALEto 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_positionsto 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.diversificationparameter, 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} } } - boostType: array integer[] · Boost Positions
_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
Nikeas the top and second recommendations:{ "boost_fq": "brand:\"Nike\"", "boost_positions": [0, 1] }If
boost_positionsis not specified (which is the default behavior), all the boosted products will be ranked higher than the rest of the products. - boostType: string · Boost Rule Name
_rule _name Name of the boosting rule. Use this to identify a boosting rule in _boosted_rules in the response
- boostingType: array string[] · Boosting Tags
_tags When
boosting_tagsis given, and there are pre-defined boost rules have the same tag(s), those boost rules will be matched, regardless if the criteria is met or not.Useful when want to force trigger specific boost campaign.
- categoryType: array string[] · Category
categoryparameter limits the search results to a particular category or sub-category. This is particularly suitable for implementing Category Pages where you want to show personalized ranking of Products under a specific category. Other filters, such asq,fq,boost_fqwill be applied on top of the category filter.A category is represented by a list of strings that correspond to its category hierarchy. For example, the following query returns Products under
Snackscategory:{ "q": "*", "category": ["Snacks"] }And the following request returns Products under
Snacks -> Chipssubcategory:{ "q": "*", "category": ["Snacks", "Chips"] } - customType: object · Custom Context
_context Dictionary of custom context variables for the current browsing session. You can specify context variables specific to your websites or apps in a
{"KEY":VALUE}format, whereKEYmust be a string, andVALUEcan be:- a
bool - a
stringor anarray of string - a
numberor anarray of numbers - an
array of objects null
In certain cases, Miso will take these variables into account when generating results.
- a
- dedupeType: boolean · Dedupe Product Group Id
_product _group _id Whether to dedupe product based on
product_group_id. Ifdedupe_product_group_id=true, Miso will prevent products with the sameproduct_group_idfrom 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.
- diversificationType: object · Diversification
Defines diversification rules to prevent products with the same attributes (e.g. sneakers made by the same brand or books from the same authors) from showing up too close to each other in the results.
For instance, customers who have purchased many of sneakers from Nike may happen to have recommendations or search results where all top-5 entries are sneakers made by Nike. Purely considering accuracy, these recommendations appear excellent since the user clearly appreciates Nike sneakers. However, such results might be considered too "plain" by the user, owing to its lack of diversity.
diversificationparameter allows you to avoid this problem by enforcing a desired minimum distance between products. For example, consider a list of four products whosebrandare Nike, Nike, Adidas, and PUMA respectively. The query below will make sure there are at least one different product between two Nike products, e.g. the diversified ranking may become Nike, Adidas, Nike, and PUMA :{ "diversification": {"brand": {"minimum_distance": 1}} }You can also increase the minimum_distance to place products further apart. For example, the following query will make sure, for the two Nike products, there are at least two other products between them. As a result, the diversified ranking may become Nike, Adidas, PUMA, and Nike.:
{ "diversification": {"brand": {"minimum_distance": 2}} }The diversification algorithm reranks the products on a best-effort basis. For example, for the product list described earlier, it is not possible to place two Nike product three places apart from each other. Therefore, the diversified ranking will still remain Nike, Adidas, PUMA, and Nike* even if we set
minimum_distance=3.- propertyType: object · DiversifyField
Name - alwaysType: boolean · Always Together
_together If always_together=true, all the products that have the same value for this field, will be put side-by-side.
- minimumType: integer · Minimum Distance
_distance Minimum distance between two products that have the same value
- enableType: boolean · Enable Boosting Campaigns
_boosting _campaigns When set to true, enable user defined boosting campaigns.
By default boosting campaigns are enabled. But you can explicitly set this to false to disable boosting campaigns.
- enableType: boolean · Enable Matched Fields
_matched _fields Determine whether to return
_matched_fieldsin the search response (default: false). Ifenable_matched_fields=true, each returned product will have an_matched_fieldsarray that shows which parts of the product catalog match the search query.For example, the following request will return
_matched_fields:{ "q": "toy story", "enable_matched_fields": true }The response will be like:
{ "data": { "products": [ { "title": "Toy Story", "_matched_fields": ["title", "metadata"] }, ... ] } }Currently,
_matched_fieldsonly contain three kinds of fields:titledescriptionmetadata, including all the fields beyond title or description in the product catalog.
- enableType: boolean · Enable Partial Match
_partial _match Enable partial match to return products that match only some of the keywords in a user's search query. By default, Miso's Search API only returns products that contain all the keywords in the search query (i.e. an AND operator over keywords). This strategy usually leads to highly relevant results. However, when we don't have enough search results to return to the users, enabling partial match allows the Search API to relax the criteria and return products that match only some of the keywords.
This strategy is particularly useful to prevent users from seeing an empty search result page and abandoning their search.
For example, let's consider the query request below:
{ "query": "Toy story 5", "enable_partial_match": true }Since there is no movie called "Toy story 5", we have zero products to return by default. However, because we set
enable_partial_matchtotrue, we will return other products that partially match the query:{ "data": { "products": [ { "title": "Toy Story", "_missing_keywords": ["5"] }, { "title": "Toy story 2", "_missing_keywords": ["5"] }, ... ], "total": 4 } }As you can see from the result above, when we don't have the exact product that the user is looking for, enabling partial match is a helpful strategy to let users know what alternatives are available, and prevent them from seeing an empty search result page.
- enableType: integer · Enable Partial Match Threshold
_partial _match _threshold If
partial_match_mode=separated, you need to provide a value forenable_partial_match_threshold. This parameter, which accepts an integer (n), creates a condition for Miso’s Search Engine to only provide partially matched results if there are n or fewer exact keyword matches. For example, if we setenable_partial_match_threshold=3, partially matched results will only be returned when there are three or fewer exact keyword matches. - enableType: boolean · Enable Semantic Search
_semantic _search Enable semantic search to return products that are semantically relevant to the search query. Semantic search is a powerful tool that further improves the partial match results. It finds products that might not contain any of the search keywords, but are highly relevant to users' search intent.
For example, consider the query:
rubbing alcohol, which is a household cleaning product. Whenenable_semantic_search=true, even if we do not have any products that matchrubbing alcohol, Miso is still able to return results like the following:{ "data": { "products": [], "total": 0, "partially_matched_products": [ { "title": "Clorox Disinfecting Wipes Multi-Surface Cleaning", "_missing_keywords": ["rubbing", "alcohol"] }, { "title": "Purell Advanced Hand Sanitizer Refreshing Gel", "_missing_keywords": ["rubbing", "alcohol"] }, ... ] } }Note that, these two products from Clorox or Purell do not contain any of the search keywords, Miso's semantic search functionality, however, is still able to identify them as good matches based on their semantic relevancy to the query
rubbing alcohol.Similarly, consider a single word search query:
aspirin. Normally, a single-word query will lead to an empty search page if we don't have products containing that word. However, whenenable_semantic_search=true, even if we do not directly haveaspirinin the product catalog, Miso is still able to return results that are highly relevant to users' search intent, such as:{ "data": { "products": [], "total": 0, "partially_matched_products": [ { "title": "Advil Pain Reliever and Fever Reducer", "_missing_keywords": ["aspirin"] }, { "title": "Tylenol Extra Strength Caplets", "_missing_keywords": ["aspirin"] }, ... ] } } - engineType: string · Engine Id
_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.
- excludeType: array string[] · Exclude
An array of
product_idsof products you want to exclude from search results. - excludeType: array · Exclude Fields From Search
_fields _from _search A list of fields you want to exclude from matching the search keywords. If not specified, all fields will be considered. Curently, only certain fields are supported for exclusion.
For example, you might exclude the
descriptionfield to improve search precision if the descriptions often contain misleading information.{ exclude_fields_from_search: ["description"] }In this example, the search will match the query against all fields except
description.- const:title
- facetType: object · Facet Filters
_filters Specifies filters to the search results based on users' selections in a faceted search UI.
For example, assume you have two facets in your faceted search UI:
genresandcustom_attributes.director. When the user selects two options in thecustom_attributes.directorfacet, you should send the following query to filter the search results for those two options (i.e.Ridley ScottorDenis Villeneuve).{ "facets": [ { "field": "genres", "size": 5 }, { "field": "custom_attributes.director", "size": 20 } ], "facet_filters": { "custom_attributes.director": { "terms": [ "Ridley Scott", "Denis Villeneuve" ] } }, }While you can use
fqparameter to achieve the same filtering capability, you should usefacet_filtersto get the correct facet counts.In a typical faceted search UI, the facet counts reflect the search result after applying filters from all but the current facets. For example, in the query below, the directors facet counts should reflect the search result after applying the filter from the genres facet, i.e.
genres:Sci-Fi. Similarly, genres facet counts should reflect the search result after applying the filter from the directors facet.facet_filterswill make the resultingfacet_countsfollow this all but except itself convention, which is rather tricky to implement withfq."facets": [ { "field": "genres", "size": 5 }, { "field": "custom_attributes.director", "size": 20 } ], "facet_filters": { "custom_attributes.director": { "terms": [ "Ridley Scott", "Denis Villeneuve" ] } }, }- propertyType: object · Filter
Name - queriesType: array object[] · Queries
- rangesType: array object[] · Ranges
- termsType: array string[] · Terms
- facetsType: array · Facets
Specifies a list of fields to create facet search against. You can specify
facetsin a string array. For example, the following query return the facet counts forcategories,tags, andcustom_attributes.director:{ "facets": [ "categories", "tags", "custom_attributes.director" ] }The response will be like:
{ "facet_counts": { "facet_fields": { "categories": [ [ "Drama", 20 ], [ "Action", 10 ], ... ], "tags": [ [ "based on novel or book", 5 ], [ "android", 4 ], ... ], "custom_attributes.director": [ [ "Ridley Scott", 26 ], [ "Andrew Abbott", 1 ], ... } }You can also specify
facetswith an object array to configure each facet individually. For example, the following query will return 20 most common facet values fortagsandcustom_attributes.directorfields, and only the directors whose names start withRidleywill be included in the director facet results.{ "facets": [ { "field": "tags", "size": 20 }, { "field": "custom_attributes.director", "size": 20, "include": "Ridley.*" } ] }- fieldType: string · Fieldrequired
The field name to create a facet against. For example, the following query will create a facet against the
custom_attributes.directorfield, and return the ten most common facet values of this field (for Products that match the search query):{ "field": "custom_attributes.director", "size": 10 } - aliasType: string · Alias
The
aliasparameter gives a unique name to a facet, especially useful when you have multiple facets on the same field.By default, facet results use the
fieldas the key. But with multiple facets on one field, this can get confusing.aliassolves this:{ "field": "custom_attributes.director", "alias": "director_facet", "size": 10 }In the response, you'll see results under the key
director_facetinstead of the field name. - excludeType: string · Exclude
The
excludeparameter filters out facet values using a regular expression. For example:{ "field": "custom_attributes.director", "size": 10, "exclude": "Steven.*" }This will omit all facet values starting with "Steven" (case-sensitive).
To exclude values with special characters, use a backslash
\or double quotes:{ "field": "custom_attributes.place_name", "size": 10, "exclude": "\"St.\".*" }This excludes facet values starting with "St.".
Remember,
excludeonly affects facet values, not the search results themselves. - includeType: string · Include
Filter facet values based on a regular expression. For example, the following query will return only the facet values that start with
Steven(case-sensitive):{ "field": "custom_attributes.director", "size": 10, "include": "Steven.*" }You can escape a special character with a preceding backslash
\or surround it with double quotes. For example, the following query will only return the facet values starting withSt.:{ "field": "custom_attributes.place_name", "size": 10, "include": "\"St.\".*" }Note that, the
includeparameter will only affect the facet values, and will not affect the search result itself. - queriesType: array object[] · Queries
Facet queries that support facet counts for any arbitrary Lucene queries, each of which is labeled by a user-friendly "key":
{ "field": "my_custom_facet", "queries": [ { "query": "price: [* TO 10] AND size:"Small"", "key": "Less than 10 dollars / Small size" }, { "query": "price: [10 TO 100] AND size:"Medium"", "key": "10 to 100 dollars / Medium size" }, { "query": "price: [100 TO *] AND size:"Large"", "key": "More than 100 dollars / Large size" } ] }In the response, Miso refers to the query result by their
key. For example, the above request will have the following response:{ "facet_counts": { "facet_fields": { "my_custom_facet": [ [ "Less than 10 dollars / Small size", 1987 ], [ "10 to 100 dollars / Medium size", 109 ], [ "More than 100 dollars / Large size", 123 ] ] } } } - rangesType: array object[] · Ranges
Facet ranges for numeric fields or date-like string fields. For example, the following query groups the products into fours buckets against on their
original_priceranges, each of which has a user-friendly "key":{ "field": "original_price", "ranges": [ {"to": 10, "key": "Less than 10 dollars"}, {"from": 10, "to": 100, "key": "10 to 100 dollars"}, {"from": 100, "to": 1000, "key": "100 to 1,000 dollars"}, {"from": 1000, "key": "More than 1,000 dollars"} ] }For each range object, you need to at least specify one of the
toorfromvalues (or both).fromis always inclusive, andtois always exclusive. In the response, Miso refers to each bucket by theirkey. For example, the above request will have the following response:{ "facet_counts": { "facet_fields": { "original_price": [ [ "Less than 10 dollars", 1987 ], [ "10 to 100 dollars", 109 ], [ "100 to 1,000 dollars", 123 ], [ "More than 1,000 dollars", 5 ] ] } } } - sizeType: integer · Size
Number of facet values to return. The facet values are sort descendingly by the number of Products that have these values (and match the search query).
- flType: array string[] · Fl
List of fields to retrieve. For example, the following request retrieves only the
titlefield of each product along with theproduct_id, which is always returned.{"fl": ["title"]}You can also match field names by using
*as a wildcard. For example, the query below retrieves thetitleand any custom attributes under theattributesdictionary.{"fl": ["title", "attributes.*"]}The following retrieves all the available fields:
{"fl": ["*"]}For the lowest latency, use an empty array to retrieve just the
product_idfield (which is the default).{"fl": []} - fqType: 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.
fqcan enable users to drill down to products with specific features based on different product attributesFor example, the query below limits the search results to only show products whose size is either
MorSand brand isNike:{"fq": "size:(\"M\" OR \"S\") AND brand:\"Nike\""}You can use
fqto apply filters against your custom attributes as well. For example, the query below limits the search results to only products whosedesignerattribute isCalvin Klein{"fq": "attributes.designer:\"Calvin Klein\""}fqcan also limit search results by numerical range. For example, the following query limits the results to products that haverating >= 4.{"fq": "rating:[4 TO *]"} - geoType: 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,
locationis used by default, but other field can also be used.Distance can be in miles or kilometers. If
distance_unitis not set,milewill 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
locfield:{ "geo": { "boost": [{ "field": "loc", "lat": 37.82667, "lon": -122.42278, "distance": 2, "distance_unit": "km" }] } }- boostType: array object[] · Boost
When set, boost products within certain geographic range from given point.
- filterType: array object[] · Filter
When set, filter result to include only products within certain geographic range from given point.
- includeType: array string[] · Include
An array of product ids you want to include into search results, regardless if main query matches.
- languageType: string · Language
Two-letter (639-1) language code of the search query. This parameter is useful when you have a multilingual product catalog that contains product metadata in different languages. If given, the search results will prioritize the products that have that specific language and match the search query. Example query:
{"language": "fr"}If not given, Miso will search against all the languages in the catalog.
- likeType: string · Like
The text snippet that we want to find products that are similar to it
- orderType: array object[] · Order By
_by A list of fields that Miso should use to sort the result, instead of Miso's default ranking order.
For example, the following query returns all the Products (because
q=*), ranked by the_personalization_scorefirst, and then by the values in thecustom_attributes.promote_scorefield in the Product catalog, then the distance between the product and New York city.{ "q": "*", "order_by": [ { "field": "_personalization_score", "tie_breaker": { "type": "relative_difference", "threshold": "0.05" }, "order": "desc" }, { "field": "custom_attributes.promote_score", "order": "desc" }, { "field": "_geo_distance", "geo": { "lat": 40.711967, "lon": -74.006076, } "order": "asc" } ] }- fieldType: string · Fieldrequired
Name of the field to order by. You can sort by any numeric and boolean fields in your Product catalog, or use one of any special fields:
- _personalization_score: the score that rates the degree of affinity between a pair of user and product from Miso's personalization algorithm.
- _search_score: the score that rates the degree of search keyword matches to a product's catalog.
- _boosting_score: the score that rates the degree a Product is boosted by your boosting query.
- defaultType: number · Default Value
_value The default value to use when the scores do not exist for a Product
- geoType: object · Geo
The geo point to compute the
_geo_distancevariable against. This is only required if_geo_distanceis present in the formula. - orderenumvalues
- desc
- asc
- tieType: object · Tie Breaker
_breaker
- partialenum
_match _mode Determine which partial match mode to enable:
-
blended (default): When
partial_match_modeisblended, keyword-matched items and semantically-matched items will be returned in the same, rank-sorted array. -
separated: When
partial_match_modeisseparated, keyword-matched items will be returned in theproductsarray and partially-matched or semantically-matched items will be returned in thepartially_matched_productsarray.
values- blended
- separated
-
blended (default): When
- personalizationType: integer · Personalization Weight
_weight min:0max:5Determines how much personalization will affect the search ranking.
- qType: string · Qmin length:1
The search query the user has entered. Miso will perform full-text search and find any Products that contain every word in this query. You can also set
q="*"to match all Products, which is commonly used along with Product filtering queryfqto implement Category Pages.(to make a search request, You need to specify either
qoradvanced_q) - queryType: object · Query Product Existence
_product _existence Additionally check if certain products will be in the search result at all (regardless of
startandrowsparameters)- productType: array string[] · Product Ids
_ids min length:1requiredA list of product ids to be checked if they will be returned in the search results
- rowsType: integer · Rows
Number of search results to return.
- semanticType: number · Semantic Search Threshold
_search _threshold Determine the threshold for semantic search. Only the products with a semantic similarity score higher than the threshold will be returned. Setting this too low (e.g. < 0.3) will result in less relevant results being returned.
- spellcheckType: object · Spellcheck
Spellcheck configuration
- enableType: boolean · Enable Auto Spelling Correction
_auto _spelling _correction This parameter controls whether to automatically correct a misspell search query. If set to
true, when Miso detects spelling errors, the search results will be based on the corrected spelling suggested by Miso.You call tell if Miso made any correction to the search query by checking the
spellcheck.auto_spelling_correctionfield in the API response. When this field istrue, the search results are based on the suggested spelling as opposed to the users' original query.You can opt-out the spelling correction by setting this parameter to
false. In such cases, Miso will still detect spelling errors, but the search results will be always based on users' original spelling.
- startType: integer · Start
Specifies an offset from which Miso will begin returning results.
The default value is
0. Setting the start parameter to some other number, such as 3, causes Miso to skip over the preceding products and start from the product identified by the offset. - typeType: 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
typeparameter to limit results to one kind of them. For instance, the following query will limit the results to only hotels product:{"type": "hotel"} - userType: object · User Cohort
_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", andgender="Female"in the User Profile dataset.{ "user_cohort": { "country": "United States", "gender": "Female" } }- property
Name - Type: boolean
- userType: string · User Hash
_hash The hash of
user_id(oranonymous_id) encrypted by your Secret API Key.user_hashis 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
- userType: string · User Id
_id The user who made the query and for whom Miso will personalize the results. For an anonymous visitor, use
anonymous_idinstead.
