diff --git a/specs/composition/paths/compositions/updateSortingStrategy.yml b/specs/composition/paths/compositions/updateSortingStrategy.yml new file mode 100644 index 00000000000..851a73ccd27 --- /dev/null +++ b/specs/composition/paths/compositions/updateSortingStrategy.yml @@ -0,0 +1,46 @@ +post: + tags: + - Compositions + operationId: updateSortingStrategyComposition + x-acl: + - editSettings + summary: Set or update the "sortingStrategy" configuration for an existing composition + description: | + 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. + parameters: + - $ref: '../urlParams.yml#/compositionID' + requestBody: + required: true + content: + application/json: + schema: + $ref: '../../common/schemas/components/Composition.yml#/sortingStrategy' + responses: + '200': + description: OK + content: + application/json: + schema: + title: taskIDResponse + type: object + additionalProperties: false + properties: + taskID: + $ref: '../../../common/responses/common.yml#/taskID' + required: + - taskID + '400': + $ref: '../../../common/responses/BadRequest.yml' + '402': + $ref: '../../../common/responses/FeatureNotEnabled.yml' + '403': + $ref: '../../../common/responses/MethodNotAllowed.yml' + '404': + $ref: '../../../common/responses/CompositionNotFound.yml' diff --git a/specs/composition/spec.yml b/specs/composition/spec.yml index 9216508ea71..c7e7ce1c504 100644 --- a/specs/composition/spec.yml +++ b/specs/composition/spec.yml @@ -136,6 +136,8 @@ paths: $ref: 'paths/compositions/composition.yml' /1/compositions/*/batch: $ref: 'paths/compositions/batch.yml' + /1/compositions/{compositionID}/sortingStrategy: + $ref: 'paths/compositions/updateSortingStrategy.yml' # ########################################## # ### Manage Composition Rules Endpoints ### diff --git a/tests/CTS/requests/composition/updateSortingStrategyComposition.json b/tests/CTS/requests/composition/updateSortingStrategyComposition.json new file mode 100644 index 00000000000..9aa759c562b --- /dev/null +++ b/tests/CTS/requests/composition/updateSortingStrategyComposition.json @@ -0,0 +1,19 @@ +[ + { + "parameters": { + "compositionID": "my-compo", + "requestBody": { + "Price-asc": "products-low-to-high", + "Price-desc": "products-high-to-low" + } + }, + "request": { + "path": "/1/compositions/my-compo/sortingStrategy", + "method": "POST", + "body": { + "Price-asc": "products-low-to-high", + "Price-desc": "products-high-to-low" + } + } + } +]