diff --git a/doc/2/api/controllers/collection/get-settings/index.md b/doc/2/api/controllers/collection/get-settings/index.md new file mode 100644 index 0000000000..7ff515f6f1 --- /dev/null +++ b/doc/2/api/controllers/collection/get-settings/index.md @@ -0,0 +1,80 @@ +--- +code: true +type: page +title: getSettings | API | Core +--- + +# getSettings + +Retrieves the Elasticsearch index settings for the specified Kuzzle collection. + +--- + +## Query Syntax + +### HTTP + +```http +URL: http://kuzzle:7512/<index>/<collection>/_settings +Method: GET +``` + +### Other protocols + +```js +{ + "index": "<index>", + "collection": "<collection>", + "controller": "collection", + "action": "getSettings", +} +``` + +--- + +## Arguments + +- `collection`: collection name +- `index`: index name + +--- + +## Response + +Returns a setting object with the following structure: + +```js +{ + "status": 200, + "error": null, + "action": "getSettings", + "controller": "collection", + "collection": "<collection>", + "index": "<index>", + "headers": {}, + "result": { + "routing": { + "allocation": { + "include": { + "_tier_preference": "data_content" + } + } + }, + "number_of_shards": "1", + "provided_name": "&platform.config", + "creation_date": "1738682329397", + "number_of_replicas": "1", + "uuid": "aY0IBbKJSvuIrwqqYyKkUw", + "version": { + "created": "7160299" + } + }, +} +``` + +--- + +## Possible errors + +- [Common errors](/core/2/api/errors/types#common-errors) +- [NotFoundError](/core/2/api/errors/types#notfounderror) diff --git a/features/CollectionController.feature b/features/CollectionController.feature index 92cc8e1aa1..0982e4c621 100644 --- a/features/CollectionController.feature +++ b/features/CollectionController.feature @@ -69,6 +69,19 @@ Feature: Collection Controller | createdAt | { "type": "date" } | | updatedAt | { "type": "date" } | + + # collection:getSettings ===================================================== + + Scenario: Get collection settings + Given an index "nyc-open-data" + And I "create" the collection "nyc-open-data":"green-taxi" with: + | mappings | { "dynamic": "strict", "properties": { "name": { "type": "keyword" } } } | + When I successfully execute the action "collection":"getSettings" with args: + | index | "nyc-open-data" | + | collection | "green-taxi" | + Then I should receive a result matching: + | number_of_shards | "1" | + # collection:delete ========================================================== Scenario: Delete a collection diff --git a/lib/api/controllers/collectionController.js b/lib/api/controllers/collectionController.js index 9b432f931e..b8c7335af7 100644 --- a/lib/api/controllers/collectionController.js +++ b/lib/api/controllers/collectionController.js @@ -36,6 +36,7 @@ class CollectionController extends NativeController { "deleteSpecifications", "exists", "getMapping", + "getSettings", "getSpecifications", "list", "refresh", @@ -97,6 +98,23 @@ class CollectionController extends NativeController { return this._filterMappingResponse(mapping); } + /** + * Get the collection settings + * + * @param {Request} request + * @returns {Promise.<Object>} + */ + async getSettings(request) { + const { index, collection } = request.getIndexAndCollection(); + + return this.ask( + "core:storage:public:collection:settings:get", + index, + collection, + {}, + ); + } + /** * Get the collection validation specifications * diff --git a/lib/api/httpRoutes.js b/lib/api/httpRoutes.js index 420b29c4dd..43a6a10aae 100644 --- a/lib/api/httpRoutes.js +++ b/lib/api/httpRoutes.js @@ -140,6 +140,12 @@ const routes = [ controller: "collection", action: "getMapping", }, + { + verb: "get", + path: "/:index/:collection/_settings", + controller: "collection", + action: "getSettings", + }, { verb: "get", path: "/:index/:collection/_search", diff --git a/test/api/controllers/collectionController.test.js b/test/api/controllers/collectionController.test.js index 31fdb912d5..a15bb6dbf7 100644 --- a/test/api/controllers/collectionController.test.js +++ b/test/api/controllers/collectionController.test.js @@ -651,7 +651,6 @@ describe("Test: collection controller", () => { index, collection, ); - should(response).be.instanceof(Object); should(response).match({ acknowledged: true,