Autosuggest
Overview
The Autosuggest feature provides query suggestions, which help your visitors search your site faster. Unbxd supports autocomplete of search queries and showcases products relevant to the query as users type.
Unbxd Autosuggest comprises different types of suggestions that are known as doctypes. A standard Unbxd Autosuggest is segmented into five doctypes:
Features | Description |
---|---|
In-fields | The In-fields doctype suggest groups of relevant products along with their associated field values the query may belong to. These field values can be categories, brands, occasion, etc. For example, a visitor types ‘Sh’, the In-field doctype will have the following suggestions: - Shirts - In Men (based on gender) - In Nike (based on brand) - In Blue (based on occasion) |
Keyword Suggestions | These are intelligent suggestions generated by Unbxd based on the query being typed and suggests relevant products based on your product feed accordingly. For example, a visitor types ‘Sh', the keyword suggestions doctype will have the following suggestions: - Shirts - Shorts - Shoes - Shapewear |
Top Queries | This doctype displays the frequently searched queries in your e-commerce store populated with the help of Unbxd Analytics, which keeps a track of your store. |
Popular Products | This doctype displays popular products with thumbnail images. Similar to Top Queries doctype, to render Popular products, Unbxd analytics needs to be integrated in your e-commerce store. |
Promoted Suggestions | These are documents that a customer can configure directly from merchandising console. For example, if a customer configures “jogging shoes” and “running shoes” as promoted suggestions, and a shopper searches for “sh”, the intended results are returned. |
Using Autosuggest Methods
Autosuggest method signature:
func search(query: SearchQuery, completion: @escaping (_ response: Any?, _ error: Error?) -> Void) {
// Handle response
}
The query of type AutoSuggestQuery
is mandatory and the rest of the arguments are optional. Below are a few samples of invoking autoSuggest()
method with different arguments.
Query method signature:
init(withKey: String, format: ResponseFormat = .JSON, inField: DocTypeInField? = nil, keywordSuggestions: DocTypeKeywordSuggestions? = nil, topQueries: DocTypeTopQueries? = nil, promotedSuggestions: DocTypePromotedSuggestions? = nil, popularProducts: DocTypePopularProducts? = nil, variant: Variant? = nil, filter: FilterAbstract? = nil)
Autosuggest method invocation:
AutoSuggestQuery
can be initialized with ‘Key’ for suggestions are expected.
let autoSuggestQuery = AutoSuggestQuery(withKey: "Shir")
client.autoSuggest(query: autoSuggestQuery, completion: {(response: Any?, error: Error?) -> Void in
//Handle response
})
Examples
Autosuggest Query:
let autoSuggestQuery = AutoSuggestQuery(withKey: "Shir")
client.autoSuggest(query: autoSuggestQuery, completion: {(response, httpResponse, err) -> Void in
//Handle response
})
Autosuggest with various doctypes:
If resultsCount
is not set, default value 2 will be considered.
In Fields: The query being typed by your visitor can belong to multiple product categories based on your product feed. The In-fields doctype in Autosuggest suggests groups of relevant products along with their associated field values the query may belong to. In Field doctype with result count can be configured as shown below:
let autoSuggestQuery = AutoSuggestQuery(withKey: "Shir", docType: DocTypeInField(resultsCount: 3))
client.autoSuggest(query: autoSuggestQuery, completion: {(response: Any?, error: Error?) -> Void in
//Handle response
})
If resultsCount
is not set, default value 2 will be considered as results count for inField doctype.
Keyword Suggestions:
These are intelligent suggestions generated by Unbxd cloud servers whose algorithm identifies the keywords from the query being typed and suggests relevant products based on your product feed accordingly.
Keyword Suggestions doctype with result count can be configured as shown below:
let autoSuggestQuery = AutoSuggestQuery(withKey: "Shir", docType: DocTypeKeywordSuggestions(resultsCount: 4))
client.autoSuggest(query: autoSuggestQuery, completion: {(response: Any?, error: Error?) -> Void in
//Handle response
})
If resultsCount
is not set, default value 2 will be considered as results count for Keyword Suggestions doctype.
Top Queries:
As the name suggests, this autosuggest doctype displays the frequently searched queries in your eCommerce store. These top queries are populated with the help of Unbxd Analytics which keeps a track of your store.
Top Queries doctype with result count can be configured as shown below:
let autoSuggestQuery = AutoSuggestQuery(withKey: "Shir", docType: DocTypeTopQueries(resultsCount: 3))
client.autoSuggest(query: autoSuggestQuery, completion: {(response: Any?, error: Error?) -> Void in
//Handle response
})
If resultsCount
is not set, default value 2 will be considered as results count for Top Queries doctype.
Promoted Suggestions:
Promoted Suggestions are documents that a customer can configure directly from merchandising console. This gives you the flexibility to manually insert keyword suggestions in autosuggest which may not be part of the default relevance results.
Promoted Suggestions doctype with result count can be configured as shown below:
let autoSuggestQuery = AutoSuggestQuery(withKey: "Shir", docType: DocTypePromotedSuggestions(resultsCount: 5))
client.autoSuggest(query: autoSuggestQuery, completion: {(response: Any?, error: Error?) -> Void in
//Handle response
})
If resultsCount
is not set, default value 2 will be considered as results count for Promoted Suggestions doctype.
Popular Products:
The Popular Products doctype displays popular product in your e-commerce store with thumbnail images.
Popular Products doctype with fields and result count can be configured as shown below:
let autoSuggestQuery = AutoSuggestQuery(withKey: "Shir", docType: DocTypePopularProducts(resultsCount: 3, fields: ["vColor","price"]))
client.autoSuggest(query: autoSuggestQuery, completion: {(response: Any?, error: Error?) -> Void in
//Handle response
})
If resultsCount
is not set, default value 3 will be considered as results count for Promoted Suggestions doctype.
Autosuggest with Filters
Filters are used in the AutoSuggest
method to restrict the products based on criteria passed.
Two types of filters are supported in autoSuggestWithQuery()
method:
- Text: It is used to filter products based on fields with string values such as color, gender, brand, etc.
- Range: It is used to filter products based on fields with data types – date, number/decimals.
Each of these filters can filter on field-name and field-id. Field-id/field-name is an optional parameter. If passed, it eliminates those products that do not match the criteria.
NOTE: If IDs are present in the feed, filtering should be done on IDs only.
Autosuggest with text filter using field ID/field name:
“filter-id” is used to filter the results using field-id. Using Field IDs, ‘IdFilter’ can be formed with two parameters:
- fieldID: The id of the field on which the text filter is applied.
- field: The id of the value on which the results are filtered.
// Using Field ID
let idFilter = IdFilter(field: "76678", value: "5001")
let autoSuggestQuery = AutoSuggestQuery(withKey: "Shir", docType: DocTypeKeywordSuggestions(resultsCount: 4), filter: idFilter)
client.autoSuggest(query: autoSuggestQuery, completion: {(response: Any?, error: Error?) -> Void in
//Handle response
})
OR
// Using Field Name
let nameFilter = NameFilter(field: "vColor_uFilter", value: "Black")
let autoSuggestQuery = AutoSuggestQuery(withKey: "Shir", docType: DocTypeKeywordSuggestions(resultsCount: 4), filter: nameFilter)
client.autoSuggest(query: autoSuggestQuery, completion: {(response: Any?, error: Error?) -> Void in
//Handle response
})
Autosuggest with Range filter using field ID/field name:
“filter-id” is used to filter the results using field-id. Using Field IDs, ‘IdFilter’ can be formed with two parameters:
- fieldID: The id of the field on which the text filter is applied.
- field: The id of the value on which the results are filtered.
// Using Field ID
let idRange = IdFilterRange(field: "76678", lower: "2034", upper: "8906")
let autoSuggestQuery = AutoSuggestQuery(withKey: "Shir", docType: DocTypeKeywordSuggestions(resultsCount: 4), filter: idRange)
client.autoSuggest(query: autoSuggestQuery, completion: {(response: Any?, error: Error?) -> Void in
//Handle response
})
OR
// Using Field Name
let nameRange = NameFilterRange(field: "vColor", lower: "red", upper: "blue")
let autoSuggestQuery = AutoSuggestQuery(withKey: "Shir", docType: DocTypeKeywordSuggestions(resultsCount: 4), filter: nameRange)
client.autoSuggest(query: autoSuggestQuery, completion: {(response: Any?, error: Error?) -> Void in
//Handle response
})
Updated 19 days ago