Skip to content

Commit

Permalink
feat(search disjunctive faceting): add request options (#840)
Browse files Browse the repository at this point in the history
  • Loading branch information
VladislavFitz committed Dec 6, 2023
1 parent 38c9991 commit 5a21b35
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 7 additions & 3 deletions Sources/AlgoliaSearchClient/Index/Index+Search.swift
Expand Up @@ -90,17 +90,19 @@ public extension Index {
- Parameter disjunctiveFacets: Set of facets attributes applied disjunctively (with OR operator)
- Parameter keepSelectedEmptyFacets: Whether the selected facet values might be preserved even
in case of their absence in the search response
- Parameter requestOptions: Configure request locally with RequestOptions.
- Returns: SearchesResponse object
*/
func searchDisjunctiveFaceting(query: Query,
refinements: [Attribute: [String]],
disjunctiveFacets: Set<Attribute>,
keepSelectedEmptyFacets: Bool = true) throws -> SearchResponse {
keepSelectedEmptyFacets: Bool = true,
requestOptions: RequestOptions? = nil) throws -> SearchResponse {
let helper = DisjunctiveFacetingHelper(query: query,
refinements: refinements,
disjunctiveFacets: disjunctiveFacets)
let queries = helper.makeQueries()
let response = try search(queries: queries)
let response = try search(queries: queries, requestOptions: requestOptions)
return try helper.mergeResponses(response.results,
keepSelectedEmptyFacets: keepSelectedEmptyFacets)
}
Expand All @@ -114,19 +116,21 @@ public extension Index {
- Parameter disjunctiveFacets: Set of facets attributes applied disjunctively (with OR operator)
- Parameter keepSelectedEmptyFacets: Whether the selected facet values might be preserved even
in case of their absence in the search response
- Parameter requestOptions: Configure request locally with RequestOptions.
- Parameter completion: Result completion
- Returns: Launched asynchronous operation
*/
func searchDisjunctiveFaceting(query: Query,
refinements: [Attribute: [String]],
disjunctiveFacets: Set<Attribute>,
keepSelectedEmptyFacets: Bool = true,
requestOptions: RequestOptions? = nil,
completion: @escaping ResultCallback<SearchResponse>) -> Operation & TransportTask {
let helper = DisjunctiveFacetingHelper(query: query,
refinements: refinements,
disjunctiveFacets: disjunctiveFacets)
let queries = helper.makeQueries()
return search(queries: queries) { result in
return search(queries: queries, requestOptions: requestOptions) { result in
completion(result.flatMap { response in
Result {
try helper.mergeResponses(response.results,
Expand Down
Expand Up @@ -20,11 +20,11 @@ extension CustomRankingCriterion: RawRepresentable {
}

public var rawValue: String {
switch self {
case .asc(let attribute):
return PrefixedString(prefix: Prefix.asc.rawValue, value: attribute.rawValue).description
case .desc(let attribute):
return PrefixedString(prefix: Prefix.desc.rawValue, value: attribute.rawValue).description
switch self {
case .asc(let attribute):
return PrefixedString(prefix: Prefix.asc.rawValue, value: attribute.rawValue).description
case .desc(let attribute):
return PrefixedString(prefix: Prefix.desc.rawValue, value: attribute.rawValue).description
}
}

Expand Down

0 comments on commit 5a21b35

Please sign in to comment.