Skip to content

Commit 3f7c7fc

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 f7b7f59 commit 3f7c7fc

File tree

3 files changed

+56
-7
lines changed

3 files changed

+56
-7
lines changed

src/main/scala/algoliasearch/api/CompositionClient.scala

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,4 +522,37 @@ class CompositionClient(
522522
execute[SearchForFacetValuesResponse](request, requestOptions)
523523
}
524524

525+
/** Updates the \"sortingStrategy\" field of an existing composition. This endpoint allows you to create a new sorting
526+
* strategy mapping or replace the currently configured one. The provided sorting indices MUST be associated indices
527+
* or replicas of the main targeted index. WARNING: This endpoint cannot validate if the sort index is related to the
528+
* composition's main index. Validation will fail at runtime if the index you updated is not related! The update is
529+
* applied to the specified composition within the current Algolia application and returns a taskID that can be used
530+
* to track the operation’s completion.
531+
*
532+
* Required API Key ACLs:
533+
* - editSettings
534+
*
535+
* @param compositionID
536+
* Unique Composition ObjectID.
537+
*/
538+
def updateSortingStrategyComposition(
539+
compositionID: String,
540+
requestBody: Map[String, String],
541+
requestOptions: Option[RequestOptions] = None
542+
)(implicit ec: ExecutionContext): Future[TaskIDResponse] = Future {
543+
requireNotNull(
544+
compositionID,
545+
"Parameter `compositionID` is required when calling `updateSortingStrategyComposition`."
546+
)
547+
requireNotNull(requestBody, "Parameter `requestBody` is required when calling `updateSortingStrategyComposition`.")
548+
549+
val request = HttpRequest
550+
.builder()
551+
.withMethod("POST")
552+
.withPath(s"/1/compositions/${escape(compositionID)}/sortingStrategy")
553+
.withBody(requestBody)
554+
.build()
555+
execute[TaskIDResponse](request, requestOptions)
556+
}
557+
525558
}

src/main/scala/algoliasearch/composition/Composition.scala

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,18 @@ package algoliasearch.composition
3636
* Composition name.
3737
* @param description
3838
* Composition description.
39+
* @param sortingStrategy
40+
* A mapping of sorting labels to the indices (or replicas) that implement those sorting rules. The sorting indices
41+
* MUST be related to the associated main targeted index in the composition. Each key is the label your frontend
42+
* sends at runtime (for example, \"Price (asc)\"), and each value is the name of the index that should be queried
43+
* when that label is selected. When a request includes a \"sortBy\" parameter, the platform looks up the
44+
* corresponding index in this mapping and uses it to execute the query. The main targeted index is replaced with the
45+
* sorting strategy index it is mapped to. Up to 20 sorting strategies can be defined.
3946
*/
4047
case class Composition(
4148
objectID: String,
4249
name: String,
4350
description: Option[String] = scala.None,
44-
behavior: CompositionBehavior
51+
behavior: CompositionBehavior,
52+
sortingStrategy: Option[Map[String, String]] = scala.None
4553
) extends BatchCompositionActionTrait

src/main/scala/algoliasearch/composition/Params.scala

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,6 @@ import algoliasearch.composition.SupportedLanguage._
102102
* Page of search results to retrieve.
103103
* @param query
104104
* Search query.
105-
* @param relevancyStrictness
106-
* Relevancy threshold below which less relevant results aren't included in the results You can only set
107-
* `relevancyStrictness` on [virtual replica
108-
* indices](https://www.algolia.com/doc/guides/managing-results/refine-results/sorting/in-depth/replicas/#what-are-virtual-replicas).
109-
* Use this setting to strike a balance between the relevance and number of returned results.
110105
* @param queryLanguages
111106
* Languages for language-specific query processing steps such as plurals, stop-word removal, and word-detection
112107
* dictionaries This setting sets a default list of languages used by the `removeStopWords` and `ignorePlurals`
@@ -118,10 +113,22 @@ import algoliasearch.composition.SupportedLanguage._
118113
* or the languages you specified with the `ignorePlurals` or `removeStopWords` parameters. This can lead to
119114
* unexpected search results. For more information, see [Language-specific
120115
* configuration](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/language-specific-configurations).
116+
* @param relevancyStrictness
117+
* Relevancy threshold below which less relevant results aren't included in the results You can only set
118+
* `relevancyStrictness` on [virtual replica
119+
* indices](https://www.algolia.com/doc/guides/managing-results/refine-results/sorting/in-depth/replicas/#what-are-virtual-replicas).
120+
* Use this setting to strike a balance between the relevance and number of returned results.
121121
* @param ruleContexts
122122
* Assigns a rule context to the run query [Rule
123123
* contexts](https://www.algolia.com/doc/guides/managing-results/rules/rules-overview/how-to/customize-search-results-by-platform/#whats-a-context)
124124
* are strings that you can use to trigger matching rules.
125+
* @param sortBy
126+
* Indicates which sorting strategy to apply for the request. The value must match one of the labels defined in the
127+
* \"sortingStrategy\" mapping. For example, \"Price (asc)\", see Upsert Composition. At runtime, this label is used
128+
* to look up the corresponding index or replica configured in \"sortingStrategy\", and the query is executed using
129+
* that index instead of main's. In addition to \"sortingStrategy\", this parameter is also used to apply a matching
130+
* Composition Rule that contains a condition defined to trigger on \"sortBy\", see Composition Rules. If no value is
131+
* provided or an invalid value, no sorting strategy is applied.
125132
* @param userToken
126133
* Unique pseudonymous or anonymous user identifier. This helps with analytics and click and conversion events. For
127134
* more information, see [user token](https://www.algolia.com/doc/guides/sending-events/concepts/usertoken).
@@ -152,8 +159,9 @@ case class Params(
152159
optionalFilters: Option[OptionalFilters] = scala.None,
153160
page: Option[Int] = scala.None,
154161
query: Option[String] = scala.None,
155-
relevancyStrictness: Option[Int] = scala.None,
156162
queryLanguages: Option[Seq[SupportedLanguage]] = scala.None,
163+
relevancyStrictness: Option[Int] = scala.None,
157164
ruleContexts: Option[Seq[String]] = scala.None,
165+
sortBy: Option[String] = scala.None,
158166
userToken: Option[String] = scala.None
159167
)

0 commit comments

Comments
 (0)