Skip to content

Commit ba32e99

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 e8ca8bf commit ba32e99

File tree

3 files changed

+157
-3
lines changed

3 files changed

+157
-3
lines changed

algoliasearch/composition/client.py

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,6 +1406,80 @@ async def search_for_facet_values(
14061406
)
14071407
return resp.deserialize(SearchForFacetValuesResponse, resp.raw_data)
14081408

1409+
async def update_sorting_strategy_composition_with_http_info(
1410+
self,
1411+
composition_id: Annotated[
1412+
StrictStr, Field(description="Unique Composition ObjectID.")
1413+
],
1414+
request_body: Dict[str, StrictStr],
1415+
request_options: Optional[Union[dict, RequestOptions]] = None,
1416+
) -> ApiResponse[str]:
1417+
"""
1418+
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.
1419+
1420+
Required API Key ACLs:
1421+
- editSettings
1422+
1423+
:param composition_id: Unique Composition ObjectID. (required)
1424+
:type composition_id: str
1425+
:param request_body: (required)
1426+
:type request_body: Dict[str, str]
1427+
: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)
1428+
:return: Returns the raw algoliasearch 'APIResponse' object.
1429+
"""
1430+
1431+
if composition_id is None:
1432+
raise ValueError(
1433+
"Parameter `composition_id` is required when calling `update_sorting_strategy_composition`."
1434+
)
1435+
1436+
if request_body is None:
1437+
raise ValueError(
1438+
"Parameter `request_body` is required when calling `update_sorting_strategy_composition`."
1439+
)
1440+
1441+
_data = {}
1442+
if request_body is not None:
1443+
_data = request_body
1444+
1445+
return await self._transporter.request(
1446+
verb=Verb.POST,
1447+
path="/1/compositions/{compositionID}/sortingStrategy".replace(
1448+
"{compositionID}", quote(str(composition_id), safe="")
1449+
),
1450+
request_options=self._request_options.merge(
1451+
data=dumps(body_serializer(_data)),
1452+
user_request_options=request_options,
1453+
),
1454+
use_read_transporter=False,
1455+
)
1456+
1457+
async def update_sorting_strategy_composition(
1458+
self,
1459+
composition_id: Annotated[
1460+
StrictStr, Field(description="Unique Composition ObjectID.")
1461+
],
1462+
request_body: Dict[str, StrictStr],
1463+
request_options: Optional[Union[dict, RequestOptions]] = None,
1464+
) -> TaskIDResponse:
1465+
"""
1466+
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.
1467+
1468+
Required API Key ACLs:
1469+
- editSettings
1470+
1471+
:param composition_id: Unique Composition ObjectID. (required)
1472+
:type composition_id: str
1473+
:param request_body: (required)
1474+
:type request_body: Dict[str, str]
1475+
: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)
1476+
:return: Returns the deserialized response in a 'TaskIDResponse' result object.
1477+
"""
1478+
resp = await self.update_sorting_strategy_composition_with_http_info(
1479+
composition_id, request_body, request_options
1480+
)
1481+
return resp.deserialize(TaskIDResponse, resp.raw_data)
1482+
14091483

14101484
class CompositionClientSync:
14111485
"""The Algolia 'CompositionClientSync' class.
@@ -2747,3 +2821,77 @@ def search_for_facet_values(
27472821
composition_id, facet_name, search_for_facet_values_request, request_options
27482822
)
27492823
return resp.deserialize(SearchForFacetValuesResponse, resp.raw_data)
2824+
2825+
def update_sorting_strategy_composition_with_http_info(
2826+
self,
2827+
composition_id: Annotated[
2828+
StrictStr, Field(description="Unique Composition ObjectID.")
2829+
],
2830+
request_body: Dict[str, StrictStr],
2831+
request_options: Optional[Union[dict, RequestOptions]] = None,
2832+
) -> ApiResponse[str]:
2833+
"""
2834+
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.
2835+
2836+
Required API Key ACLs:
2837+
- editSettings
2838+
2839+
:param composition_id: Unique Composition ObjectID. (required)
2840+
:type composition_id: str
2841+
:param request_body: (required)
2842+
:type request_body: Dict[str, str]
2843+
: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)
2844+
:return: Returns the raw algoliasearch 'APIResponse' object.
2845+
"""
2846+
2847+
if composition_id is None:
2848+
raise ValueError(
2849+
"Parameter `composition_id` is required when calling `update_sorting_strategy_composition`."
2850+
)
2851+
2852+
if request_body is None:
2853+
raise ValueError(
2854+
"Parameter `request_body` is required when calling `update_sorting_strategy_composition`."
2855+
)
2856+
2857+
_data = {}
2858+
if request_body is not None:
2859+
_data = request_body
2860+
2861+
return self._transporter.request(
2862+
verb=Verb.POST,
2863+
path="/1/compositions/{compositionID}/sortingStrategy".replace(
2864+
"{compositionID}", quote(str(composition_id), safe="")
2865+
),
2866+
request_options=self._request_options.merge(
2867+
data=dumps(body_serializer(_data)),
2868+
user_request_options=request_options,
2869+
),
2870+
use_read_transporter=False,
2871+
)
2872+
2873+
def update_sorting_strategy_composition(
2874+
self,
2875+
composition_id: Annotated[
2876+
StrictStr, Field(description="Unique Composition ObjectID.")
2877+
],
2878+
request_body: Dict[str, StrictStr],
2879+
request_options: Optional[Union[dict, RequestOptions]] = None,
2880+
) -> TaskIDResponse:
2881+
"""
2882+
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.
2883+
2884+
Required API Key ACLs:
2885+
- editSettings
2886+
2887+
:param composition_id: Unique Composition ObjectID. (required)
2888+
:type composition_id: str
2889+
:param request_body: (required)
2890+
:type request_body: Dict[str, str]
2891+
: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)
2892+
:return: Returns the deserialized response in a 'TaskIDResponse' result object.
2893+
"""
2894+
resp = self.update_sorting_strategy_composition_with_http_info(
2895+
composition_id, request_body, request_options
2896+
)
2897+
return resp.deserialize(TaskIDResponse, resp.raw_data)

algoliasearch/composition/models/composition.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"name": "name",
2626
"description": "description",
2727
"behavior": "behavior",
28+
"sorting_strategy": "sortingStrategy",
2829
}
2930

3031

@@ -44,6 +45,8 @@ class Composition(BaseModel):
4445
description: Optional[str] = None
4546
""" Composition description. """
4647
behavior: CompositionBehavior
48+
sorting_strategy: Optional[Dict[str, str]] = None
49+
""" 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. """
4750

4851
model_config = ConfigDict(
4952
strict=False,

algoliasearch/composition/models/params.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,10 @@
5353
"optional_filters": "optionalFilters",
5454
"page": "page",
5555
"query": "query",
56-
"relevancy_strictness": "relevancyStrictness",
5756
"query_languages": "queryLanguages",
57+
"relevancy_strictness": "relevancyStrictness",
5858
"rule_contexts": "ruleContexts",
59+
"sort_by": "sortBy",
5960
"user_token": "userToken",
6061
}
6162

@@ -113,12 +114,14 @@ class Params(BaseModel):
113114
""" Page of search results to retrieve. """
114115
query: Optional[str] = None
115116
""" Search query. """
116-
relevancy_strictness: Optional[int] = None
117-
""" 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. """
118117
query_languages: Optional[List[SupportedLanguage]] = None
119118
""" 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). """
119+
relevancy_strictness: Optional[int] = None
120+
""" 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. """
120121
rule_contexts: Optional[List[str]] = None
121122
""" 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. """
123+
sort_by: Optional[str] = None
124+
""" 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. """
122125
user_token: Optional[str] = None
123126
""" 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). """
124127

0 commit comments

Comments
 (0)