Skip to content

Commit fd50dbe

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 <accounts+algolia-api-client-bot@algolia.com> Co-authored-by: Ben Kalmus <ben.kalmus@algolia.com> Co-authored-by: Thomas Raffray <Fluf22@users.noreply.github.com>
1 parent 7fc549e commit fd50dbe

File tree

3 files changed

+134
-14
lines changed

3 files changed

+134
-14
lines changed

algoliasearch/Clients/CompositionClient.cs

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,48 @@ SearchForFacetValuesResponse SearchForFacetValues(
727727
RequestOptions options = null,
728728
CancellationToken cancellationToken = default
729729
);
730+
731+
/// <summary>
732+
/// 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.
733+
/// </summary>
734+
///
735+
/// Required API Key ACLs:
736+
/// - editSettings
737+
/// <param name="compositionID">Unique Composition ObjectID.</param>
738+
/// <param name="requestBody"></param>
739+
/// <param name="options">Add extra http header or query parameters to Algolia.</param>
740+
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
741+
/// <exception cref="ArgumentException">Thrown when arguments are not correct</exception>
742+
/// <exception cref="Algolia.Search.Exceptions.AlgoliaApiException">Thrown when the API call was rejected by Algolia</exception>
743+
/// <exception cref="Algolia.Search.Exceptions.AlgoliaUnreachableHostException">Thrown when the client failed to call the endpoint</exception>
744+
/// <returns>Task of TaskIDResponse</returns>
745+
Task<TaskIDResponse> UpdateSortingStrategyCompositionAsync(
746+
string compositionID,
747+
Dictionary<string, string> requestBody,
748+
RequestOptions options = null,
749+
CancellationToken cancellationToken = default
750+
);
751+
752+
/// <summary>
753+
/// 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. (Synchronous version)
754+
/// </summary>
755+
///
756+
/// Required API Key ACLs:
757+
/// - editSettings
758+
/// <param name="compositionID">Unique Composition ObjectID.</param>
759+
/// <param name="requestBody"></param>
760+
/// <param name="options">Add extra http header or query parameters to Algolia.</param>
761+
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
762+
/// <exception cref="ArgumentException">Thrown when arguments are not correct</exception>
763+
/// <exception cref="Algolia.Search.Exceptions.AlgoliaApiException">Thrown when the API call was rejected by Algolia</exception>
764+
/// <exception cref="Algolia.Search.Exceptions.AlgoliaUnreachableHostException">Thrown when the client failed to call the endpoint</exception>
765+
/// <returns>TaskIDResponse</returns>
766+
TaskIDResponse UpdateSortingStrategyComposition(
767+
string compositionID,
768+
Dictionary<string, string> requestBody,
769+
RequestOptions options = null,
770+
CancellationToken cancellationToken = default
771+
);
730772
}
731773

732774
/// <summary>
@@ -1498,4 +1540,51 @@ public SearchForFacetValuesResponse SearchForFacetValues(
14981540
cancellationToken
14991541
)
15001542
);
1543+
1544+
/// <inheritdoc />
1545+
public async Task<TaskIDResponse> UpdateSortingStrategyCompositionAsync(
1546+
string compositionID,
1547+
Dictionary<string, string> requestBody,
1548+
RequestOptions options = null,
1549+
CancellationToken cancellationToken = default
1550+
)
1551+
{
1552+
if (compositionID == null)
1553+
throw new ArgumentException(
1554+
"Parameter `compositionID` is required when calling `UpdateSortingStrategyComposition`."
1555+
);
1556+
1557+
if (requestBody == null)
1558+
throw new ArgumentException(
1559+
"Parameter `requestBody` is required when calling `UpdateSortingStrategyComposition`."
1560+
);
1561+
1562+
var requestOptions = new InternalRequestOptions(options);
1563+
1564+
requestOptions.PathParameters.Add(
1565+
"compositionID",
1566+
QueryStringHelper.ParameterToString(compositionID)
1567+
);
1568+
1569+
requestOptions.Data = requestBody;
1570+
return await _transport
1571+
.ExecuteRequestAsync<TaskIDResponse>(
1572+
new HttpMethod("POST"),
1573+
"/1/compositions/{compositionID}/sortingStrategy",
1574+
requestOptions,
1575+
cancellationToken
1576+
)
1577+
.ConfigureAwait(false);
1578+
}
1579+
1580+
/// <inheritdoc />
1581+
public TaskIDResponse UpdateSortingStrategyComposition(
1582+
string compositionID,
1583+
Dictionary<string, string> requestBody,
1584+
RequestOptions options = null,
1585+
CancellationToken cancellationToken = default
1586+
) =>
1587+
AsyncHelper.RunSync(() =>
1588+
UpdateSortingStrategyCompositionAsync(compositionID, requestBody, options, cancellationToken)
1589+
);
15011590
}

algoliasearch/Models/Composition/Composition.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ public Composition(string objectID, string name, CompositionBehavior behavior)
6262
[JsonPropertyName("behavior")]
6363
public CompositionBehavior Behavior { get; set; }
6464

65+
/// <summary>
66+
/// 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.
67+
/// </summary>
68+
/// <value>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. </value>
69+
[JsonPropertyName("sortingStrategy")]
70+
public Dictionary<string, string> SortingStrategy { get; set; }
71+
6572
/// <summary>
6673
/// Returns the string presentation of the object
6774
/// </summary>
@@ -74,6 +81,7 @@ public override string ToString()
7481
sb.Append(" Name: ").Append(Name).Append("\n");
7582
sb.Append(" Description: ").Append(Description).Append("\n");
7683
sb.Append(" Behavior: ").Append(Behavior).Append("\n");
84+
sb.Append(" SortingStrategy: ").Append(SortingStrategy).Append("\n");
7785
sb.Append("}\n");
7886
return sb.ToString();
7987
}
@@ -105,7 +113,13 @@ public override bool Equals(object obj)
105113
Description == input.Description
106114
|| (Description != null && Description.Equals(input.Description))
107115
)
108-
&& (Behavior == input.Behavior || (Behavior != null && Behavior.Equals(input.Behavior)));
116+
&& (Behavior == input.Behavior || (Behavior != null && Behavior.Equals(input.Behavior)))
117+
&& (
118+
SortingStrategy == input.SortingStrategy
119+
|| SortingStrategy != null
120+
&& input.SortingStrategy != null
121+
&& SortingStrategy.SequenceEqual(input.SortingStrategy)
122+
);
109123
}
110124

111125
/// <summary>
@@ -133,6 +147,10 @@ public override int GetHashCode()
133147
{
134148
hashCode = (hashCode * 59) + Behavior.GetHashCode();
135149
}
150+
if (SortingStrategy != null)
151+
{
152+
hashCode = (hashCode * 59) + SortingStrategy.GetHashCode();
153+
}
136154
return hashCode;
137155
}
138156
}

algoliasearch/Models/Composition/Params.cs

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -190,27 +190,34 @@ public Params() { }
190190
[JsonPropertyName("query")]
191191
public string Query { get; set; }
192192

193-
/// <summary>
194-
/// 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.
195-
/// </summary>
196-
/// <value>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. </value>
197-
[JsonPropertyName("relevancyStrictness")]
198-
public int? RelevancyStrictness { get; set; }
199-
200193
/// <summary>
201194
/// 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).
202195
/// </summary>
203196
/// <value>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). </value>
204197
[JsonPropertyName("queryLanguages")]
205198
public List<SupportedLanguage> QueryLanguages { get; set; }
206199

200+
/// <summary>
201+
/// 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.
202+
/// </summary>
203+
/// <value>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. </value>
204+
[JsonPropertyName("relevancyStrictness")]
205+
public int? RelevancyStrictness { get; set; }
206+
207207
/// <summary>
208208
/// 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.
209209
/// </summary>
210210
/// <value>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. </value>
211211
[JsonPropertyName("ruleContexts")]
212212
public List<string> RuleContexts { get; set; }
213213

214+
/// <summary>
215+
/// 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.
216+
/// </summary>
217+
/// <value>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. </value>
218+
[JsonPropertyName("sortBy")]
219+
public string SortBy { get; set; }
220+
214221
/// <summary>
215222
/// 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).
216223
/// </summary>
@@ -251,9 +258,10 @@ public override string ToString()
251258
sb.Append(" OptionalFilters: ").Append(OptionalFilters).Append("\n");
252259
sb.Append(" Page: ").Append(Page).Append("\n");
253260
sb.Append(" Query: ").Append(Query).Append("\n");
254-
sb.Append(" RelevancyStrictness: ").Append(RelevancyStrictness).Append("\n");
255261
sb.Append(" QueryLanguages: ").Append(QueryLanguages).Append("\n");
262+
sb.Append(" RelevancyStrictness: ").Append(RelevancyStrictness).Append("\n");
256263
sb.Append(" RuleContexts: ").Append(RuleContexts).Append("\n");
264+
sb.Append(" SortBy: ").Append(SortBy).Append("\n");
257265
sb.Append(" UserToken: ").Append(UserToken).Append("\n");
258266
sb.Append("}\n");
259267
return sb.ToString();
@@ -358,22 +366,23 @@ public override bool Equals(object obj)
358366
)
359367
&& (Page == input.Page || Page.Equals(input.Page))
360368
&& (Query == input.Query || (Query != null && Query.Equals(input.Query)))
361-
&& (
362-
RelevancyStrictness == input.RelevancyStrictness
363-
|| RelevancyStrictness.Equals(input.RelevancyStrictness)
364-
)
365369
&& (
366370
QueryLanguages == input.QueryLanguages
367371
|| QueryLanguages != null
368372
&& input.QueryLanguages != null
369373
&& QueryLanguages.SequenceEqual(input.QueryLanguages)
370374
)
375+
&& (
376+
RelevancyStrictness == input.RelevancyStrictness
377+
|| RelevancyStrictness.Equals(input.RelevancyStrictness)
378+
)
371379
&& (
372380
RuleContexts == input.RuleContexts
373381
|| RuleContexts != null
374382
&& input.RuleContexts != null
375383
&& RuleContexts.SequenceEqual(input.RuleContexts)
376384
)
385+
&& (SortBy == input.SortBy || (SortBy != null && SortBy.Equals(input.SortBy)))
377386
&& (UserToken == input.UserToken || (UserToken != null && UserToken.Equals(input.UserToken)));
378387
}
379388

@@ -453,15 +462,19 @@ public override int GetHashCode()
453462
{
454463
hashCode = (hashCode * 59) + Query.GetHashCode();
455464
}
456-
hashCode = (hashCode * 59) + RelevancyStrictness.GetHashCode();
457465
if (QueryLanguages != null)
458466
{
459467
hashCode = (hashCode * 59) + QueryLanguages.GetHashCode();
460468
}
469+
hashCode = (hashCode * 59) + RelevancyStrictness.GetHashCode();
461470
if (RuleContexts != null)
462471
{
463472
hashCode = (hashCode * 59) + RuleContexts.GetHashCode();
464473
}
474+
if (SortBy != null)
475+
{
476+
hashCode = (hashCode * 59) + SortBy.GetHashCode();
477+
}
465478
if (UserToken != null)
466479
{
467480
hashCode = (hashCode * 59) + UserToken.GetHashCode();

0 commit comments

Comments
 (0)