Skip to content

Commit 1e507c5

Browse files
algolia-botFluf22
andcommitted
feat(kotlin): add disjunctive faceting (generated)
algolia/api-clients-automation#3789 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Thomas Raffray <[email protected]>
1 parent 5da9052 commit 1e507c5

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

Sources/Search/Extra/DisjunctiveFaceting.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ struct DisjunctiveFacetingHelper {
4242

4343
/// Build search queries to fetch the necessary facets information for disjunctive faceting
4444
/// If the disjunctive facets set is empty, makes a single request with applied conjunctive filters
45-
func makeQueries() -> [SearchQuery] {
45+
func buildQueries() -> [SearchQuery] {
4646
var queries = [SearchQuery]()
4747

4848
var mainQuery = self.query
@@ -89,8 +89,7 @@ struct DisjunctiveFacetingHelper {
8989

9090
/// Merge received search responses into single one with combined facets information
9191
func mergeResponses<T: Codable>(
92-
_ responses: [SearchResponse<T>],
93-
keepSelectedEmptyFacets _: Bool = true
92+
_ responses: [SearchResponse<T>]
9493
) throws -> SearchDisjunctiveFacetingResponse<T> {
9594
guard var mainResponse = responses.first else {
9695
throw DisjunctiveFacetingError.emptyResponses

Sources/Search/Extra/SearchClientExtension.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,8 @@ public extension SearchClient {
644644
/// - Parameter searchParamsObject: The search query params.
645645
/// - Parameter refinements: Refinements to apply to the search in form of dictionary with
646646
/// facet attribute as a key and a list of facet values for the designated attribute.
647-
/// Any facet in this list not present in the `disjunctiveFacets` set will be filtered conjunctively.
647+
/// Any facet in this list not present in the `disjunctiveFacets` set will be filtered conjunctively (with AND
648+
/// operator).
648649
/// - Parameter disjunctiveFacets: Set of facets attributes applied disjunctively (with OR operator)
649650
/// - Parameter keepSelectedEmptyFacets: Whether the selected facet values might be preserved even
650651
/// in case of their absence in the search response
@@ -657,19 +658,18 @@ public extension SearchClient {
657658
searchParamsObject: SearchSearchParamsObject,
658659
refinements: [String: [String]],
659660
disjunctiveFacets: Set<String>,
660-
keepSelectedEmptyFacets: Bool = true,
661661
requestOptions: RequestOptions? = nil
662662
) async throws -> SearchDisjunctiveFacetingResponse<T> {
663663
let helper = DisjunctiveFacetingHelper(
664664
query: SearchForHits(from: searchParamsObject, indexName: indexName),
665665
refinements: refinements,
666666
disjunctiveFacets: disjunctiveFacets
667667
)
668-
let queries = helper.makeQueries()
668+
let queries = helper.buildQueries()
669669
let responses: [SearchResponse<T>] = try await self.searchForHitsWithResponse(
670670
searchMethodParams: SearchMethodParams(requests: queries),
671671
requestOptions: requestOptions
672672
)
673-
return try helper.mergeResponses(responses, keepSelectedEmptyFacets: keepSelectedEmptyFacets)
673+
return try helper.mergeResponses(responses)
674674
}
675675
}

0 commit comments

Comments
 (0)