CIORecommendationsQueryBuilder
public class CIORecommendationsQueryBuilder
Request builder for creating a recommendations query
-
Create a Recommendations request query builder
Declaration
Swift
public init(podID: String)
Parameters
podID
The pod ID
-
Add an item id to retrieve recommendations for (strategy specific)
Declaration
Swift
public func setItemID(_ itemID: String) -> CIORecommendationsQueryBuilder
-
Add a term to refine results (strategy specific)
Declaration
Swift
public func setTerm(_ term: String) -> CIORecommendationsQueryBuilder
-
Add the number of results to return
Declaration
Swift
public func setNumResults(_ numResults: Int) -> CIORecommendationsQueryBuilder
-
Add additional filters
Declaration
Swift
public func setFilters(_ filters: CIOQueryFilters) -> CIORecommendationsQueryBuilder
-
Add the number of results to return per page
Declaration
Swift
public func setSection(_ section: String) -> CIORecommendationsQueryBuilder
-
Add a list of hidden metadata fields to return
Declaration
Swift
public func setHiddenFields(_ hiddenFields: [String]) -> CIORecommendationsQueryBuilder
-
Add the pre filter expression
Declaration
Swift
public func setPreFilterExpression(_ preFilterExpression: String) -> CIORecommendationsQueryBuilder
-
Build the request object with all of the provided data
Usage Example:
let preFilterExpression = "{\"or\":[{\"and\":[{\"name\":\"group_id\",\"value\":\"electronics-group-id\"},{\"name\":\"Price\",\"range\":[\"-inf\",200.0]}]},{\"and\":[{\"name\":\"Type\",\"value\":\"Laptop\"},{\"not\":{\"name\":\"Price\",\"range\":[800.0,\"inf\"]}}]}]}" let query = CIORecommendationsQueryBuilder(query: "blue") .setFilters(CIOQueryFilters(groupFilter: nil, facetFilters: facetFilters)) .setItemID("ITEM_123_456") .setNumResults(10) .setSection("Products") .setHiddenFields(["hidden_price_field", "color_swatches"]) .setPreFilterExpression(preFilterExpression) .build() constructor.recommendations(forQuery: query, completionHandler: { ... })
Declaration
Swift
public func build() -> CIORecommendationsQuery