Skip to content

Commit

Permalink
fix(specs): make the searchParams compatible with v4 [skip-bc] (gener…
Browse files Browse the repository at this point in the history
…ated)

algolia/api-clients-automation#4108

Co-authored-by: algolia-bot <[email protected]>
Co-authored-by: Pierre Millot <[email protected]>
  • Loading branch information
algolia-bot and millotp committed Nov 15, 2024
1 parent 0d11c4c commit 083a522
Show file tree
Hide file tree
Showing 23 changed files with 326 additions and 337 deletions.
25 changes: 2 additions & 23 deletions Sources/Recommend/Models/BaseRecommendIndexSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,7 @@ public struct BaseRecommendIndexSettings: Codable, JSONEncodable {
/// Whether to support phrase matching and excluding words from search queries. Use the `advancedSyntaxFeatures`
/// parameter to control which feature is supported.
public var advancedSyntax: Bool?
/// Words that should be considered optional when found in the query. By default, records must match all words in
/// the search query to be included in the search results. Adding optional words can help to increase the number of
/// search results by running an additional search query that doesn't include the optional words. For example, if
/// the search query is \"action video\" and \"video\" is an optional word, the search engine runs two queries. One
/// for \"action video\" and one for \"action\". Records that match all words are ranked higher. For a search query
/// with 4 or more words **and** all its words are optional, the number of matched words required for a record to be
/// included in the search results increases for every 1,000 records: - If `optionalWords` has less than 10 words,
/// the required number of matched words increases by 1: results 1 to 1,000 require 1 matched word, results 1,001
/// to 2000 need 2 matched words. - If `optionalWords` has 10 or more words, the number of required matched words
/// increases by the number of optional words divided by 5 (rounded down). For example, with 18 optional words:
/// results 1 to 1,000 require 1 matched word, results 1,001 to 2000 need 4 matched words. For more information,
/// see [Optional words](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/empty-or-insufficient-results/#creating-a-list-of-optional-words).
public var optionalWords: [String]?
public var optionalWords: RecommendOptionalWords?
/// Searchable attributes for which you want to [turn off the Exact ranking criterion](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/override-search-engine-defaults/in-depth/adjust-exact-settings/#turn-off-exact-for-some-attributes).
/// Attribute names are case-sensitive. This can be useful for attributes with long values, where the likelihood of
/// an exact match is high, such as product descriptions. Turning off the Exact ranking criterion for these
Expand Down Expand Up @@ -138,9 +126,6 @@ public struct BaseRecommendIndexSettings: Codable, JSONEncodable {
/// `parsedQuery`, or any property triggered by the `getRankingInfo` parameter. Don't exclude properties that you
/// might need in your search UI.
public var responseFields: [String]?
/// Maximum number of facet values to return when [searching for facet
/// values](https://www.algolia.com/doc/guides/managing-results/refine-results/faceting/#search-for-facet-values).
public var maxFacetHits: Int?
/// Maximum number of facet values to return for each facet.
public var maxValuesPerFacet: Int?
/// Order in which to retrieve facet values. - `count`. Facet values are retrieved by decreasing count. The
Expand Down Expand Up @@ -184,7 +169,7 @@ public struct BaseRecommendIndexSettings: Codable, JSONEncodable {
queryType: RecommendQueryType? = nil,
removeWordsIfNoResults: RecommendRemoveWordsIfNoResults? = nil,
advancedSyntax: Bool? = nil,
optionalWords: [String]? = nil,
optionalWords: RecommendOptionalWords? = nil,
disableExactOnAttributes: [String]? = nil,
exactOnSingleWordQuery: RecommendExactOnSingleWordQuery? = nil,
alternativesAsExact: [RecommendAlternativesAsExact]? = nil,
Expand All @@ -193,7 +178,6 @@ public struct BaseRecommendIndexSettings: Codable, JSONEncodable {
replaceSynonymsInHighlight: Bool? = nil,
minProximity: Int? = nil,
responseFields: [String]? = nil,
maxFacetHits: Int? = nil,
maxValuesPerFacet: Int? = nil,
sortFacetValuesBy: String? = nil,
attributeCriteriaComputedByMinProximity: Bool? = nil,
Expand Down Expand Up @@ -233,7 +217,6 @@ public struct BaseRecommendIndexSettings: Codable, JSONEncodable {
self.replaceSynonymsInHighlight = replaceSynonymsInHighlight
self.minProximity = minProximity
self.responseFields = responseFields
self.maxFacetHits = maxFacetHits
self.maxValuesPerFacet = maxValuesPerFacet
self.sortFacetValuesBy = sortFacetValuesBy
self.attributeCriteriaComputedByMinProximity = attributeCriteriaComputedByMinProximity
Expand Down Expand Up @@ -275,7 +258,6 @@ public struct BaseRecommendIndexSettings: Codable, JSONEncodable {
case replaceSynonymsInHighlight
case minProximity
case responseFields
case maxFacetHits
case maxValuesPerFacet
case sortFacetValuesBy
case attributeCriteriaComputedByMinProximity
Expand Down Expand Up @@ -323,7 +305,6 @@ public struct BaseRecommendIndexSettings: Codable, JSONEncodable {
try container.encodeIfPresent(self.replaceSynonymsInHighlight, forKey: .replaceSynonymsInHighlight)
try container.encodeIfPresent(self.minProximity, forKey: .minProximity)
try container.encodeIfPresent(self.responseFields, forKey: .responseFields)
try container.encodeIfPresent(self.maxFacetHits, forKey: .maxFacetHits)
try container.encodeIfPresent(self.maxValuesPerFacet, forKey: .maxValuesPerFacet)
try container.encodeIfPresent(self.sortFacetValuesBy, forKey: .sortFacetValuesBy)
try container.encodeIfPresent(
Expand Down Expand Up @@ -370,7 +351,6 @@ extension BaseRecommendIndexSettings: Equatable {
lhs.replaceSynonymsInHighlight == rhs.replaceSynonymsInHighlight &&
lhs.minProximity == rhs.minProximity &&
lhs.responseFields == rhs.responseFields &&
lhs.maxFacetHits == rhs.maxFacetHits &&
lhs.maxValuesPerFacet == rhs.maxValuesPerFacet &&
lhs.sortFacetValuesBy == rhs.sortFacetValuesBy &&
lhs.attributeCriteriaComputedByMinProximity == rhs.attributeCriteriaComputedByMinProximity &&
Expand Down Expand Up @@ -414,7 +394,6 @@ extension BaseRecommendIndexSettings: Hashable {
hasher.combine(self.replaceSynonymsInHighlight?.hashValue)
hasher.combine(self.minProximity?.hashValue)
hasher.combine(self.responseFields?.hashValue)
hasher.combine(self.maxFacetHits?.hashValue)
hasher.combine(self.maxValuesPerFacet?.hashValue)
hasher.combine(self.sortFacetValuesBy?.hashValue)
hasher.combine(self.attributeCriteriaComputedByMinProximity?.hashValue)
Expand Down
7 changes: 2 additions & 5 deletions Sources/Recommend/Models/BaseRecommendSearchParams.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ public struct BaseRecommendSearchParams: Codable, JSONEncodable {
public var aroundPrecision: RecommendAroundPrecision?
/// Minimum radius (in meters) for a search around a location when `aroundRadius` isn't set.
public var minimumAroundRadius: Int?
/// Coordinates for a rectangular area in which to search. Each bounding box is defined by the two opposite points
/// of its diagonal, and expressed as latitude and longitude pair: `[p1 lat, p1 long, p2 lat, p2 long]`. Provide
/// multiple bounding boxes as nested arrays. For more information, see [rectangular area](https://www.algolia.com/doc/guides/managing-results/refine-results/geolocation/#filtering-inside-rectangular-or-polygonal-areas).
public var insideBoundingBox: [[Double]]?
public var insideBoundingBox: RecommendInsideBoundingBox?
/// Coordinates of a polygon in which to search. Polygons are defined by 3 to 10,000 points. Each point is
/// represented by its latitude and longitude. Provide multiple polygons as nested arrays. For more information, see
/// [filtering inside polygons](https://www.algolia.com/doc/guides/managing-results/refine-results/geolocation/#filtering-inside-rectangular-or-polygonal-areas).
Expand Down Expand Up @@ -112,7 +109,7 @@ public struct BaseRecommendSearchParams: Codable, JSONEncodable {
aroundRadius: RecommendAroundRadius? = nil,
aroundPrecision: RecommendAroundPrecision? = nil,
minimumAroundRadius: Int? = nil,
insideBoundingBox: [[Double]]? = nil,
insideBoundingBox: RecommendInsideBoundingBox? = nil,
insidePolygon: [[Double]]? = nil,
naturalLanguages: [RecommendSupportedLanguage]? = nil,
ruleContexts: [String]? = nil,
Expand Down
41 changes: 13 additions & 28 deletions Sources/Recommend/Models/FallbackParams.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ public struct FallbackParams: Codable, JSONEncodable {
public var aroundPrecision: RecommendAroundPrecision?
/// Minimum radius (in meters) for a search around a location when `aroundRadius` isn't set.
public var minimumAroundRadius: Int?
/// Coordinates for a rectangular area in which to search. Each bounding box is defined by the two opposite points
/// of its diagonal, and expressed as latitude and longitude pair: `[p1 lat, p1 long, p2 lat, p2 long]`. Provide
/// multiple bounding boxes as nested arrays. For more information, see [rectangular area](https://www.algolia.com/doc/guides/managing-results/refine-results/geolocation/#filtering-inside-rectangular-or-polygonal-areas).
public var insideBoundingBox: [[Double]]?
public var insideBoundingBox: RecommendInsideBoundingBox?
/// Coordinates of a polygon in which to search. Polygons are defined by 3 to 10,000 points. Each point is
/// represented by its latitude and longitude. Provide multiple polygons as nested arrays. For more information, see
/// [filtering inside polygons](https://www.algolia.com/doc/guides/managing-results/refine-results/geolocation/#filtering-inside-rectangular-or-polygonal-areas).
Expand Down Expand Up @@ -189,6 +186,9 @@ public struct FallbackParams: Codable, JSONEncodable {
/// to use the same attribute also for faceting, use the `afterDistinct` modifier of the `attributesForFaceting`
/// setting. This applies faceting _after_ deduplication, which will result in accurate facet counts.
public var attributeForDistinct: String?
/// Maximum number of facet values to return when [searching for facet
/// values](https://www.algolia.com/doc/guides/managing-results/refine-results/faceting/#search-for-facet-values).
public var maxFacetHits: Int?
/// Attributes to include in the API response. To reduce the size of your response, you can retrieve only some of
/// the attributes. Attribute names are case-sensitive. - `*` retrieves all attributes, except attributes included
/// in the `customRanking` and `unretrievableAttributes` settings. - To retrieve all attributes except a specific
Expand Down Expand Up @@ -268,19 +268,7 @@ public struct FallbackParams: Codable, JSONEncodable {
/// Whether to support phrase matching and excluding words from search queries. Use the `advancedSyntaxFeatures`
/// parameter to control which feature is supported.
public var advancedSyntax: Bool?
/// Words that should be considered optional when found in the query. By default, records must match all words in
/// the search query to be included in the search results. Adding optional words can help to increase the number of
/// search results by running an additional search query that doesn't include the optional words. For example, if
/// the search query is \"action video\" and \"video\" is an optional word, the search engine runs two queries. One
/// for \"action video\" and one for \"action\". Records that match all words are ranked higher. For a search query
/// with 4 or more words **and** all its words are optional, the number of matched words required for a record to be
/// included in the search results increases for every 1,000 records: - If `optionalWords` has less than 10 words,
/// the required number of matched words increases by 1: results 1 to 1,000 require 1 matched word, results 1,001
/// to 2000 need 2 matched words. - If `optionalWords` has 10 or more words, the number of required matched words
/// increases by the number of optional words divided by 5 (rounded down). For example, with 18 optional words:
/// results 1 to 1,000 require 1 matched word, results 1,001 to 2000 need 4 matched words. For more information,
/// see [Optional words](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/empty-or-insufficient-results/#creating-a-list-of-optional-words).
public var optionalWords: [String]?
public var optionalWords: RecommendOptionalWords?
/// Searchable attributes for which you want to [turn off the Exact ranking criterion](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/override-search-engine-defaults/in-depth/adjust-exact-settings/#turn-off-exact-for-some-attributes).
/// Attribute names are case-sensitive. This can be useful for attributes with long values, where the likelihood of
/// an exact match is high, such as product descriptions. Turning off the Exact ranking criterion for these
Expand Down Expand Up @@ -320,9 +308,6 @@ public struct FallbackParams: Codable, JSONEncodable {
/// `parsedQuery`, or any property triggered by the `getRankingInfo` parameter. Don't exclude properties that you
/// might need in your search UI.
public var responseFields: [String]?
/// Maximum number of facet values to return when [searching for facet
/// values](https://www.algolia.com/doc/guides/managing-results/refine-results/faceting/#search-for-facet-values).
public var maxFacetHits: Int?
/// Maximum number of facet values to return for each facet.
public var maxValuesPerFacet: Int?
/// Order in which to retrieve facet values. - `count`. Facet values are retrieved by decreasing count. The
Expand Down Expand Up @@ -358,7 +343,7 @@ public struct FallbackParams: Codable, JSONEncodable {
aroundRadius: RecommendAroundRadius? = nil,
aroundPrecision: RecommendAroundPrecision? = nil,
minimumAroundRadius: Int? = nil,
insideBoundingBox: [[Double]]? = nil,
insideBoundingBox: RecommendInsideBoundingBox? = nil,
insidePolygon: [[Double]]? = nil,
naturalLanguages: [RecommendSupportedLanguage]? = nil,
ruleContexts: [String]? = nil,
Expand Down Expand Up @@ -389,6 +374,7 @@ public struct FallbackParams: Codable, JSONEncodable {
userData: AnyCodable? = nil,
customNormalization: [String: [String: String]]? = nil,
attributeForDistinct: String? = nil,
maxFacetHits: Int? = nil,
attributesToRetrieve: [String]? = nil,
ranking: [String]? = nil,
relevancyStrictness: Int? = nil,
Expand All @@ -412,7 +398,7 @@ public struct FallbackParams: Codable, JSONEncodable {
queryType: RecommendQueryType? = nil,
removeWordsIfNoResults: RecommendRemoveWordsIfNoResults? = nil,
advancedSyntax: Bool? = nil,
optionalWords: [String]? = nil,
optionalWords: RecommendOptionalWords? = nil,
disableExactOnAttributes: [String]? = nil,
exactOnSingleWordQuery: RecommendExactOnSingleWordQuery? = nil,
alternativesAsExact: [RecommendAlternativesAsExact]? = nil,
Expand All @@ -421,7 +407,6 @@ public struct FallbackParams: Codable, JSONEncodable {
replaceSynonymsInHighlight: Bool? = nil,
minProximity: Int? = nil,
responseFields: [String]? = nil,
maxFacetHits: Int? = nil,
maxValuesPerFacet: Int? = nil,
sortFacetValuesBy: String? = nil,
attributeCriteriaComputedByMinProximity: Bool? = nil,
Expand Down Expand Up @@ -475,6 +460,7 @@ public struct FallbackParams: Codable, JSONEncodable {
self.userData = userData
self.customNormalization = customNormalization
self.attributeForDistinct = attributeForDistinct
self.maxFacetHits = maxFacetHits
self.attributesToRetrieve = attributesToRetrieve
self.ranking = ranking
self.relevancyStrictness = relevancyStrictness
Expand Down Expand Up @@ -507,7 +493,6 @@ public struct FallbackParams: Codable, JSONEncodable {
self.replaceSynonymsInHighlight = replaceSynonymsInHighlight
self.minProximity = minProximity
self.responseFields = responseFields
self.maxFacetHits = maxFacetHits
self.maxValuesPerFacet = maxValuesPerFacet
self.sortFacetValuesBy = sortFacetValuesBy
self.attributeCriteriaComputedByMinProximity = attributeCriteriaComputedByMinProximity
Expand Down Expand Up @@ -563,6 +548,7 @@ public struct FallbackParams: Codable, JSONEncodable {
case userData
case customNormalization
case attributeForDistinct
case maxFacetHits
case attributesToRetrieve
case ranking
case relevancyStrictness
Expand Down Expand Up @@ -595,7 +581,6 @@ public struct FallbackParams: Codable, JSONEncodable {
case replaceSynonymsInHighlight
case minProximity
case responseFields
case maxFacetHits
case maxValuesPerFacet
case sortFacetValuesBy
case attributeCriteriaComputedByMinProximity
Expand Down Expand Up @@ -654,6 +639,7 @@ public struct FallbackParams: Codable, JSONEncodable {
try container.encodeIfPresent(self.userData, forKey: .userData)
try container.encodeIfPresent(self.customNormalization, forKey: .customNormalization)
try container.encodeIfPresent(self.attributeForDistinct, forKey: .attributeForDistinct)
try container.encodeIfPresent(self.maxFacetHits, forKey: .maxFacetHits)
try container.encodeIfPresent(self.attributesToRetrieve, forKey: .attributesToRetrieve)
try container.encodeIfPresent(self.ranking, forKey: .ranking)
try container.encodeIfPresent(self.relevancyStrictness, forKey: .relevancyStrictness)
Expand Down Expand Up @@ -689,7 +675,6 @@ public struct FallbackParams: Codable, JSONEncodable {
try container.encodeIfPresent(self.replaceSynonymsInHighlight, forKey: .replaceSynonymsInHighlight)
try container.encodeIfPresent(self.minProximity, forKey: .minProximity)
try container.encodeIfPresent(self.responseFields, forKey: .responseFields)
try container.encodeIfPresent(self.maxFacetHits, forKey: .maxFacetHits)
try container.encodeIfPresent(self.maxValuesPerFacet, forKey: .maxValuesPerFacet)
try container.encodeIfPresent(self.sortFacetValuesBy, forKey: .sortFacetValuesBy)
try container.encodeIfPresent(
Expand Down Expand Up @@ -750,6 +735,7 @@ extension FallbackParams: Equatable {
lhs.userData == rhs.userData &&
lhs.customNormalization == rhs.customNormalization &&
lhs.attributeForDistinct == rhs.attributeForDistinct &&
lhs.maxFacetHits == rhs.maxFacetHits &&
lhs.attributesToRetrieve == rhs.attributesToRetrieve &&
lhs.ranking == rhs.ranking &&
lhs.relevancyStrictness == rhs.relevancyStrictness &&
Expand Down Expand Up @@ -782,7 +768,6 @@ extension FallbackParams: Equatable {
lhs.replaceSynonymsInHighlight == rhs.replaceSynonymsInHighlight &&
lhs.minProximity == rhs.minProximity &&
lhs.responseFields == rhs.responseFields &&
lhs.maxFacetHits == rhs.maxFacetHits &&
lhs.maxValuesPerFacet == rhs.maxValuesPerFacet &&
lhs.sortFacetValuesBy == rhs.sortFacetValuesBy &&
lhs.attributeCriteriaComputedByMinProximity == rhs.attributeCriteriaComputedByMinProximity &&
Expand Down Expand Up @@ -840,6 +825,7 @@ extension FallbackParams: Hashable {
hasher.combine(self.userData?.hashValue)
hasher.combine(self.customNormalization?.hashValue)
hasher.combine(self.attributeForDistinct?.hashValue)
hasher.combine(self.maxFacetHits?.hashValue)
hasher.combine(self.attributesToRetrieve?.hashValue)
hasher.combine(self.ranking?.hashValue)
hasher.combine(self.relevancyStrictness?.hashValue)
Expand Down Expand Up @@ -872,7 +858,6 @@ extension FallbackParams: Hashable {
hasher.combine(self.replaceSynonymsInHighlight?.hashValue)
hasher.combine(self.minProximity?.hashValue)
hasher.combine(self.responseFields?.hashValue)
hasher.combine(self.maxFacetHits?.hashValue)
hasher.combine(self.maxValuesPerFacet?.hashValue)
hasher.combine(self.sortFacetValuesBy?.hashValue)
hasher.combine(self.attributeCriteriaComputedByMinProximity?.hashValue)
Expand Down
Loading

0 comments on commit 083a522

Please sign in to comment.