1.3.9. /db/_shards

GET /{db}/_shards

The response will contain a list of database shards. Each shard will have its internal database range, and the nodes on which replicas of those shards are stored.

  • Parameters

    • db – Database name

    Request Headers

    • Accept

      • application/json

      • text/plain

    Response Headers

      • application/json

      • text/plain; charset=utf-8

    Response JSON Object

    • shards (object) – Mapping of shard ranges to individual shard replicas on each node in the cluster

    Status Codes

    • 200 OK – Request completed successfully

    • – Invalid database name

    • 401 Unauthorized – Read privilege required

    • – Bad Content-Type value

    • – Internal server error or timeout

Request:

Response:

  1. HTTP/1.1 200 OK
  2. Cache-Control: must-revalidate
  3. Content-Length: 621
  4. Content-Type: application/json
  5. Date: Fri, 18 Jan 2019 19:55:14 GMT
  6. Server: CouchDB/2.4.0 (Erlang OTP/19)
  7. {
  8. "shards": {
  9. "00000000-1fffffff": [
  10. "couchdb@node1.example.com",
  11. "couchdb@node2.example.com",
  12. "couchdb@node3.example.com"
  13. ],
  14. "20000000-3fffffff": [
  15. "couchdb@node1.example.com",
  16. "couchdb@node2.example.com",
  17. "couchdb@node3.example.com"
  18. ],
  19. "40000000-5fffffff": [
  20. "couchdb@node1.example.com",
  21. "couchdb@node2.example.com",
  22. "couchdb@node3.example.com"
  23. ],
  24. "60000000-7fffffff": [
  25. "couchdb@node2.example.com",
  26. "couchdb@node3.example.com"
  27. ],
  28. "80000000-9fffffff": [
  29. "couchdb@node1.example.com",
  30. "couchdb@node2.example.com",
  31. "couchdb@node3.example.com"
  32. ],
  33. "a0000000-bfffffff": [
  34. "couchdb@node1.example.com",
  35. "couchdb@node2.example.com",
  36. "couchdb@node3.example.com"
  37. ],
  38. "c0000000-dfffffff": [
  39. "couchdb@node1.example.com",
  40. "couchdb@node2.example.com",
  41. "couchdb@node3.example.com"
  42. ],
  43. "e0000000-ffffffff": [
  44. "couchdb@node1.example.com",
  45. "couchdb@node2.example.com",
  46. "couchdb@node3.example.com"
  47. ]
  48. }
  49. }

1.3.10. /db/_shards/doc

GET /{db}/_shards/{docid}

Returns information about the specific shard into which a given document has been stored, along with information about the nodes on which that shard has a replica.

    • db – Database name

    • docid – Document ID

    Request Headers

      • application/json

      • text/plain

    Response Headers

    • Content-Type

      • application/json

      • text/plain; charset=utf-8

    Response JSON Object

    • range (string) – The shard range in which the document is stored

    • nodes (array) – List of nodes serving a replica of the shard

    Status Codes

Request:

Response:

  1. HTTP/1.1 200 OK
  2. Content-Type: application/json
  3. Date: Fri, 18 Jan 2019 20:26:33 GMT
  4. Server: CouchDB/2.3.0-9d4cb03c2 (Erlang OTP/19)
  5. {
  6. "range": "e0000000-ffffffff",
  7. "nodes": [
  8. "node1@127.0.0.1",
  9. "node2@127.0.0.1",
  10. "node3@127.0.0.1"
  11. ]
  12. }

1.3.11. /db/_sync_shards

New in version 2.3.1.

POST /{db}/_sync_shards

This is typically only used when performing cluster maintenance, such as moving a shard.

  • Parameters

    • db – Database name

    Request Headers

      • application/json

      • text/plain

    Response Headers

    • Content-Type

      • application/json

      • text/plain; charset=utf-8

    Response JSON Object

    • ok (boolean) – Operation status. Available in case of success

    • error (string) – Error type. Available if response code is 4xx

    • reason (string) – Error description. Available if response code is 4xx

    Status Codes

    • – Request accepted

    • 400 Bad Request – Invalid database name

    • – CouchDB Server Administrator privileges required

    • 404 Not Found – Database not found

    • – Internal server error or timeout

Request:

Response:

  1. HTTP/1.1 202 Accepted
  2. Cache-Control: must-revalidate
  3. Content-Length: 12
  4. Content-Type: application/json
  5. Date: Fri, 18 Jan 2019 20:19:23 GMT
  6. Server: CouchDB/2.3.0-9d4cb03c2 (Erlang OTP/19)
  7. X-Couch-Request-ID: 14f0b8d252
  8. X-CouchDB-Body-Time: 0
  9. {
  10. "ok": true
  11. }

Admins may want to bump their [mem3] sync_concurrency value to a larger figure for the duration of the shards sync.