api-conventions.asciidoc 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. [[api-conventions]]
  2. = API Conventions
  3. [partintro]
  4. --
  5. The *elasticsearch* REST APIs are exposed using:
  6. * <<modules-http,JSON over HTTP>>,
  7. * <<modules-thrift,thrift>>,
  8. * <<modules-memcached,memcached>>.
  9. The conventions listed in this chapter can be applied throughout the REST
  10. API, unless otherwise specified.
  11. * <<multi-index>>
  12. * <<common-options>>
  13. --
  14. [[multi-index]]
  15. == Multiple Indices
  16. Most APIs that refer to an `index` paramter support execution across multiple indices,
  17. using simple `test1,test2,test3` notation (or `_all` for all indices). It also
  18. support wildcards, for example: `test*`, and the ability to "add" (`+`)
  19. and "remove" (`-`), for example: `+test*,-test3`.
  20. All multi indices API support the `ignore_indices` option. Setting it to
  21. `missing` will cause indices that do not exists to be ignored from the
  22. execution. By default, when its not set, the request will fail.
  23. NOTE: Single index APIs such as the <<docs>> and the
  24. <<indices-aliases,single-index `alias` APIs>> do not support multiple indices.
  25. [[common-options]]
  26. == Common options
  27. The following options can be applied to all of the REST APIs.
  28. [float]
  29. === Pretty Results
  30. When appending `?pretty=true` to any request made, the JSON returned
  31. will be pretty formatted (use it for debugging only!). Another option is
  32. to set `format=yaml` which will cause the result to be returned in the
  33. (sometimes) more readable yaml format.
  34. [float]
  35. === Human readable output
  36. Statistics are returned in a format suitable for humans
  37. (eg `"exists_time": "1h"` or `"size": "1kb"`) and for computers
  38. (eg `"exists_time_in_millis": 3600000`` or `"size_in_bytes": 1024`).
  39. The human readable values can be turned off by adding `?human=false`
  40. to the query string. This makes sense when the stats results are
  41. being consumed by a monitoring tool, rather than intended for human
  42. consumption. The default for the `human` flag is
  43. `false`. added[1.00.Beta,Previously defaulted to `true`]
  44. [float]
  45. === Parameters
  46. Rest parameters (when using HTTP, map to HTTP URL parameters) follow the
  47. convention of using underscore casing.
  48. [float]
  49. === Boolean Values
  50. All REST APIs parameters (both request parameters and JSON body) support
  51. providing boolean "false" as the values: `false`, `0`, `no` and `off`.
  52. All other values are considered "true". Note, this is not related to
  53. fields within a document indexed treated as boolean fields.
  54. [float]
  55. === Number Values
  56. All REST APIs support providing numbered parameters as `string` on top
  57. of supporting the native JSON number types.
  58. [float]
  59. === Result Casing
  60. All REST APIs accept the `case` parameter. When set to `camelCase`, all
  61. field names in the result will be returned in camel casing, otherwise,
  62. underscore casing will be used. Note, this does not apply to the source
  63. document indexed.
  64. [float]
  65. === JSONP
  66. All REST APIs accept a `callback` parameter resulting in a
  67. http://en.wikipedia.org/wiki/JSONP[JSONP] result.
  68. [float]
  69. === Request body in query string
  70. For libraries that don't accept a request body for non-POST requests,
  71. you can pass the request body as the `source` query string parameter
  72. instead.