CIOAutocompleteQueryBuilder

public class CIOAutocompleteQueryBuilder

Request builder for creating a autocomplete query

  • Create a Autocomplete request query builder

    Declaration

    Swift

    public init(query: String)

    Parameters

    query

    The user typed query to return results for

  • Add the number of results to return per page

    Declaration

    Swift

    public func setNumResults(_ numResults: Int) -> CIOAutocompleteQueryBuilder
  • Add a sort option

    Declaration

    Swift

    public func setNumResultsForSection(_ numResultsForSection: [String : Int]) -> CIOAutocompleteQueryBuilder
  • Add additional filters

    Declaration

    Swift

    public func setFilters(_ filters: CIOQueryFilters) -> CIOAutocompleteQueryBuilder
  • Add additional filters applied only to specific sections

    Declaration

    Swift

    public func setSectionFilters(_ sectionFilters: [String : CIOQueryFilters]) -> CIOAutocompleteQueryBuilder
  • Add a list of hidden fields to return

    Declaration

    Swift

    public func setHiddenFields(_ hiddenFields: [String]) -> CIOAutocompleteQueryBuilder
  • Add a variations map to return per variation

    Declaration

    Swift

    public func setVariationsMap(_ variationsMap: CIOQueryVariationsMap) -> CIOAutocompleteQueryBuilder
  • Build the request object with all of the provided data

    Usage Example:

    let facetFilters = [(key: "availability", value: "US")]
    
    let query = CIOAutocompleteQueryBuilder(query: "blue")
       .setNumResultsForSection([
           "Products": 5,
           "Search Suggestions": 5
       ])
       .setFilters(CIOQueryFilters(groupFilter: nil, facetFilters: facetFilters))
       .setHiddenFields(["hidden_price_field", "color_swatches"])
       .build()
    
    constructor.autocomplete(forQuery: query, completionHandler: { ... })
    

    Declaration

    Swift

    public func build() -> CIOAutocompleteQuery