Skip to content

Commit 0c5351a

Browse files
algolia-botben-kalmusFluf22
committed
feat(specs): add sortBy query param and sortingStrategy (generated)
algolia/api-clients-automation#5686 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Ben Kalmus <[email protected]> Co-authored-by: Thomas Raffray <[email protected]>
1 parent 0fa7cc2 commit 0c5351a

File tree

3 files changed

+94
-15
lines changed

3 files changed

+94
-15
lines changed

lib/algolia/api/composition_client.rb

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -947,5 +947,61 @@ def search_for_facet_values(composition_id, facet_name, search_for_facet_values_
947947
)
948948
end
949949

950+
# Updates the \"sortingStrategy\" field of an existing composition. This endpoint allows you to create a new sorting strategy mapping or replace the currently configured one. The provided sorting indices MUST be associated indices or replicas of the main targeted index. WARNING: This endpoint cannot validate if the sort index is related to the composition's main index. Validation will fail at runtime if the index you updated is not related! The update is applied to the specified composition within the current Algolia application and returns a taskID that can be used to track the operation’s completion.
951+
#
952+
# Required API Key ACLs:
953+
# - editSettings
954+
# @param composition_id [String] Unique Composition ObjectID. (required)
955+
# @param request_body [Hash<String, String>] (required)
956+
# @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)
957+
# @return [Http::Response] the response
958+
def update_sorting_strategy_composition_with_http_info(composition_id, request_body, request_options = {})
959+
# verify the required parameter 'composition_id' is set
960+
if @api_client.config.client_side_validation && composition_id.nil?
961+
raise(
962+
ArgumentError,
963+
"Parameter `composition_id` is required when calling `update_sorting_strategy_composition`."
964+
)
965+
end
966+
# verify the required parameter 'request_body' is set
967+
if @api_client.config.client_side_validation && request_body.nil?
968+
raise ArgumentError, "Parameter `request_body` is required when calling `update_sorting_strategy_composition`."
969+
end
970+
971+
path = "/1/compositions/{compositionID}/sortingStrategy".sub(
972+
"{" + "compositionID" + "}",
973+
Transport.encode_uri(composition_id.to_s)
974+
)
975+
query_params = {}
976+
query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
977+
header_params = {}
978+
header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?
979+
980+
post_body = request_options[:debug_body] || @api_client.object_to_http_body(request_body)
981+
982+
new_options = request_options.merge(
983+
:operation => :"CompositionClient.update_sorting_strategy_composition",
984+
:header_params => header_params,
985+
:query_params => query_params,
986+
:body => post_body,
987+
:use_read_transporter => false
988+
)
989+
990+
@api_client.call_api(:POST, path, new_options)
991+
end
992+
993+
# Updates the \"sortingStrategy\" field of an existing composition. This endpoint allows you to create a new sorting strategy mapping or replace the currently configured one. The provided sorting indices MUST be associated indices or replicas of the main targeted index. WARNING: This endpoint cannot validate if the sort index is related to the composition's main index. Validation will fail at runtime if the index you updated is not related! The update is applied to the specified composition within the current Algolia application and returns a taskID that can be used to track the operation’s completion.
994+
#
995+
# Required API Key ACLs:
996+
# - editSettings
997+
# @param composition_id [String] Unique Composition ObjectID. (required)
998+
# @param request_body [Hash<String, String>] (required)
999+
# @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)
1000+
# @return [TaskIDResponse]
1001+
def update_sorting_strategy_composition(composition_id, request_body, request_options = {})
1002+
response = update_sorting_strategy_composition_with_http_info(composition_id, request_body, request_options)
1003+
@api_client.deserialize(response.body, request_options[:debug_return_type] || "Composition::TaskIDResponse")
1004+
end
1005+
9501006
end
9511007
end

lib/algolia/models/composition/composition.rb

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,17 @@ class Composition
1919

2020
attr_accessor :behavior
2121

22+
# A mapping of sorting labels to the indices (or replicas) that implement those sorting rules. The sorting indices MUST be related to the associated main targeted index in the composition. Each key is the label your frontend sends at runtime (for example, \"Price (asc)\"), and each value is the name of the index that should be queried when that label is selected. When a request includes a \"sortBy\" parameter, the platform looks up the corresponding index in this mapping and uses it to execute the query. The main targeted index is replaced with the sorting strategy index it is mapped to. Up to 20 sorting strategies can be defined.
23+
attr_accessor :sorting_strategy
24+
2225
# Attribute mapping from ruby-style variable name to JSON key.
2326
def self.attribute_map
2427
{
2528
:algolia_object_id => :objectID,
2629
:name => :name,
2730
:description => :description,
28-
:behavior => :behavior
31+
:behavior => :behavior,
32+
:sorting_strategy => :sortingStrategy
2933
}
3034
end
3135

@@ -35,7 +39,8 @@ def self.types_mapping
3539
:algolia_object_id => :"String",
3640
:name => :"String",
3741
:description => :"String",
38-
:behavior => :"CompositionBehavior"
42+
:behavior => :"CompositionBehavior",
43+
:sorting_strategy => :"Hash<String, String>"
3944
}
4045
end
4146

@@ -90,6 +95,12 @@ def initialize(attributes = {})
9095
else
9196
self.behavior = nil
9297
end
98+
99+
if attributes.key?(:sorting_strategy)
100+
if (value = attributes[:sorting_strategy]).is_a?(Hash)
101+
self.sorting_strategy = value
102+
end
103+
end
93104
end
94105

95106
# Checks equality by comparing each attribute.
@@ -100,7 +111,8 @@ def ==(other)
100111
algolia_object_id == other.algolia_object_id &&
101112
name == other.name &&
102113
description == other.description &&
103-
behavior == other.behavior
114+
behavior == other.behavior &&
115+
sorting_strategy == other.sorting_strategy
104116
end
105117

106118
# @see the `==` method
@@ -112,7 +124,7 @@ def eql?(other)
112124
# Calculates hash code according to all attributes.
113125
# @return [Integer] Hash code
114126
def hash
115-
[algolia_object_id, name, description, behavior].hash
127+
[algolia_object_id, name, description, behavior, sorting_strategy].hash
116128
end
117129

118130
# Builds the object from hash

lib/algolia/models/composition/params.rb

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,18 @@ class Params
7777
# Search query.
7878
attr_accessor :query
7979

80-
# Relevancy threshold below which less relevant results aren't included in the results You can only set `relevancyStrictness` on [virtual replica indices](https://www.algolia.com/doc/guides/managing-results/refine-results/sorting/in-depth/replicas/#what-are-virtual-replicas). Use this setting to strike a balance between the relevance and number of returned results.
81-
attr_accessor :relevancy_strictness
82-
8380
# Languages for language-specific query processing steps such as plurals, stop-word removal, and word-detection dictionaries This setting sets a default list of languages used by the `removeStopWords` and `ignorePlurals` settings. This setting also sets a dictionary for word detection in the logogram-based [CJK](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/normalization/#normalization-for-logogram-based-languages-cjk) languages. To support this, you must place the CJK language **first** **You should always specify a query language.** If you don't specify an indexing language, the search engine uses all [supported languages](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/supported-languages), or the languages you specified with the `ignorePlurals` or `removeStopWords` parameters. This can lead to unexpected search results. For more information, see [Language-specific configuration](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/language-specific-configurations).
8481
attr_accessor :query_languages
8582

83+
# Relevancy threshold below which less relevant results aren't included in the results You can only set `relevancyStrictness` on [virtual replica indices](https://www.algolia.com/doc/guides/managing-results/refine-results/sorting/in-depth/replicas/#what-are-virtual-replicas). Use this setting to strike a balance between the relevance and number of returned results.
84+
attr_accessor :relevancy_strictness
85+
8686
# Assigns a rule context to the run query [Rule contexts](https://www.algolia.com/doc/guides/managing-results/rules/rules-overview/how-to/customize-search-results-by-platform/#whats-a-context) are strings that you can use to trigger matching rules.
8787
attr_accessor :rule_contexts
8888

89+
# Indicates which sorting strategy to apply for the request. The value must match one of the labels defined in the \"sortingStrategy\" mapping. For example, \"Price (asc)\", see Upsert Composition. At runtime, this label is used to look up the corresponding index or replica configured in \"sortingStrategy\", and the query is executed using that index instead of main's. In addition to \"sortingStrategy\", this parameter is also used to apply a matching Composition Rule that contains a condition defined to trigger on \"sortBy\", see Composition Rules. If no value is provided or an invalid value, no sorting strategy is applied.
90+
attr_accessor :sort_by
91+
8992
# Unique pseudonymous or anonymous user identifier. This helps with analytics and click and conversion events. For more information, see [user token](https://www.algolia.com/doc/guides/sending-events/concepts/usertoken).
9093
attr_accessor :user_token
9194

@@ -117,9 +120,10 @@ def self.attribute_map
117120
:optional_filters => :optionalFilters,
118121
:page => :page,
119122
:query => :query,
120-
:relevancy_strictness => :relevancyStrictness,
121123
:query_languages => :queryLanguages,
124+
:relevancy_strictness => :relevancyStrictness,
122125
:rule_contexts => :ruleContexts,
126+
:sort_by => :sortBy,
123127
:user_token => :userToken
124128
}
125129
end
@@ -152,9 +156,10 @@ def self.types_mapping
152156
:optional_filters => :"OptionalFilters",
153157
:page => :"Integer",
154158
:query => :"String",
155-
:relevancy_strictness => :"Integer",
156159
:query_languages => :"Array<SupportedLanguage>",
160+
:relevancy_strictness => :"Integer",
157161
:rule_contexts => :"Array<String>",
162+
:sort_by => :"String",
158163
:user_token => :"String"
159164
}
160165
end
@@ -298,22 +303,26 @@ def initialize(attributes = {})
298303
self.query = attributes[:query]
299304
end
300305

301-
if attributes.key?(:relevancy_strictness)
302-
self.relevancy_strictness = attributes[:relevancy_strictness]
303-
end
304-
305306
if attributes.key?(:query_languages)
306307
if (value = attributes[:query_languages]).is_a?(Array)
307308
self.query_languages = value
308309
end
309310
end
310311

312+
if attributes.key?(:relevancy_strictness)
313+
self.relevancy_strictness = attributes[:relevancy_strictness]
314+
end
315+
311316
if attributes.key?(:rule_contexts)
312317
if (value = attributes[:rule_contexts]).is_a?(Array)
313318
self.rule_contexts = value
314319
end
315320
end
316321

322+
if attributes.key?(:sort_by)
323+
self.sort_by = attributes[:sort_by]
324+
end
325+
317326
if attributes.key?(:user_token)
318327
self.user_token = attributes[:user_token]
319328
end
@@ -349,9 +358,10 @@ def ==(other)
349358
optional_filters == other.optional_filters &&
350359
page == other.page &&
351360
query == other.query &&
352-
relevancy_strictness == other.relevancy_strictness &&
353361
query_languages == other.query_languages &&
362+
relevancy_strictness == other.relevancy_strictness &&
354363
rule_contexts == other.rule_contexts &&
364+
sort_by == other.sort_by &&
355365
user_token == other.user_token
356366
end
357367

@@ -390,9 +400,10 @@ def hash
390400
optional_filters,
391401
page,
392402
query,
393-
relevancy_strictness,
394403
query_languages,
404+
relevancy_strictness,
395405
rule_contexts,
406+
sort_by,
396407
user_token
397408
].hash
398409
end

0 commit comments

Comments
 (0)