Skip to content

Commit 19c2e13

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 38ea0ac commit 19c2e13

File tree

4 files changed

+66
-4
lines changed

4 files changed

+66
-4
lines changed

packages/composition/model/clientMethodProps.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,17 @@ export type SearchForFacetValuesProps = {
224224
searchForFacetValuesRequest?: SearchForFacetValuesRequest | undefined;
225225
};
226226

227+
/**
228+
* Properties for the `updateSortingStrategyComposition` method.
229+
*/
230+
export type UpdateSortingStrategyCompositionProps = {
231+
/**
232+
* Unique Composition ObjectID.
233+
*/
234+
compositionID: string;
235+
requestBody: { [key: string]: string };
236+
};
237+
227238
export type WaitForCompositionTaskOptions = {
228239
/**
229240
* The maximum number of retries. 50 by default.

packages/composition/model/composition.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,9 @@ export type Composition = {
1919
description?: string | undefined;
2020

2121
behavior: CompositionBehavior;
22+
23+
/**
24+
* 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.
25+
*/
26+
sortingStrategy?: { [key: string]: string } | undefined;
2227
};

packages/composition/model/params.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,20 +118,25 @@ export type Params = {
118118
query?: string | undefined;
119119

120120
/**
121-
* 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.
121+
* 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).
122122
*/
123-
relevancyStrictness?: number | undefined;
123+
queryLanguages?: Array<SupportedLanguage> | undefined;
124124

125125
/**
126-
* 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).
126+
* 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.
127127
*/
128-
queryLanguages?: Array<SupportedLanguage> | undefined;
128+
relevancyStrictness?: number | undefined;
129129

130130
/**
131131
* 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.
132132
*/
133133
ruleContexts?: Array<string> | undefined;
134134

135+
/**
136+
* 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.
137+
*/
138+
sortBy?: string | undefined;
139+
135140
/**
136141
* 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).
137142
*/

packages/composition/src/compositionClient.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import type {
4343
SearchCompositionRulesProps,
4444
SearchForFacetValuesProps,
4545
SearchProps,
46+
UpdateSortingStrategyCompositionProps,
4647
WaitForCompositionTaskOptions,
4748
} from '../model/clientMethodProps';
4849

@@ -822,5 +823,45 @@ export function createCompositionClient({
822823

823824
return transporter.request(request, requestOptions);
824825
},
826+
827+
/**
828+
* 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.
829+
*
830+
* Required API Key ACLs:
831+
* - editSettings
832+
* @param updateSortingStrategyComposition - The updateSortingStrategyComposition object.
833+
* @param updateSortingStrategyComposition.compositionID - Unique Composition ObjectID.
834+
* @param updateSortingStrategyComposition.requestBody - The requestBody object.
835+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
836+
*/
837+
updateSortingStrategyComposition(
838+
{ compositionID, requestBody }: UpdateSortingStrategyCompositionProps,
839+
requestOptions?: RequestOptions,
840+
): Promise<TaskIDResponse> {
841+
if (!compositionID) {
842+
throw new Error('Parameter `compositionID` is required when calling `updateSortingStrategyComposition`.');
843+
}
844+
845+
if (!requestBody) {
846+
throw new Error('Parameter `requestBody` is required when calling `updateSortingStrategyComposition`.');
847+
}
848+
849+
const requestPath = '/1/compositions/{compositionID}/sortingStrategy'.replace(
850+
'{compositionID}',
851+
encodeURIComponent(compositionID),
852+
);
853+
const headers: Headers = {};
854+
const queryParameters: QueryParameters = {};
855+
856+
const request: Request = {
857+
method: 'POST',
858+
path: requestPath,
859+
queryParameters,
860+
headers,
861+
data: requestBody,
862+
};
863+
864+
return transporter.request(request, requestOptions);
865+
},
825866
};
826867
}

0 commit comments

Comments
 (0)