put-search-application.asciidoc 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. [role="xpack"]
  2. [[put-search-application]]
  3. === Put Search Application
  4. preview::[]
  5. ++++
  6. <titleabbrev>Put Search Application</titleabbrev>
  7. ++++
  8. Creates or updates a Search Application.
  9. [[put-search-application-request]]
  10. ==== {api-request-title}
  11. `PUT _application/search_application/<name>`
  12. [[put-search-application-prereqs]]
  13. ==== {api-prereq-title}
  14. Requires the `manage_search_application` cluster privilege.
  15. Also requires <<privileges-list-indices,manage privileges>> on all indices that are added to the Search Application.
  16. [[put-search-application-path-params]]
  17. ==== {api-path-parms-title}
  18. `create`::
  19. (Optional, Boolean) If `true`, this request cannot replace or update existing Search Applications.
  20. Defaults to `false`.
  21. `<body>`::
  22. (Required, object)
  23. Contains parameters for a search application:
  24. +
  25. .Properties of `<body>` objects
  26. [%collapsible%open]
  27. ====
  28. `indices`::
  29. (Required, array of strings)
  30. The <<indices,indices>> associated with this search application. All indices need to exist in order to be added to a search application.
  31. `template`::
  32. (Optional, object)
  33. The <<search-template,search template>> associated with this search application. The search application's template is only stored and accessible through the search application.
  34. - This search template must be a Mustache template.
  35. - The template must contain a Mustache script and script source.
  36. - The template may be modified with subsequent <<put-search-application,put search application>> requests.
  37. - If no template is specified when creating a search application, or if a template is removed from a search application, we use the <<query-string-query-ex-request,query_string>> defined in the template examples as a default.
  38. - This template will be used by the <<search-application-search,search application search>> API to execute searches.
  39. ====
  40. [[put-search-application-response-codes]]
  41. ==== {api-response-codes-title}
  42. `404`::
  43. Search Application `<name>` does not exist.
  44. `409`::
  45. Search Application `<name>` exists and `create` is `true`.
  46. [[put-search-application-example]]
  47. ==== {api-examples-title}
  48. The following example creates a new Search Application called `my-app`:
  49. [source,console]
  50. ----
  51. PUT _application/search_application/my-app?create
  52. {
  53. "indices": [ "index1", "index2" ],
  54. "template": {
  55. "script": {
  56. "source": {
  57. "query": {
  58. "query_string": {
  59. "query": "{{query_string}}",
  60. "default_field": "{{default_field}}"
  61. }
  62. }
  63. },
  64. "params": {
  65. "query_string": "*",
  66. "default_field": "*"
  67. }
  68. }
  69. }
  70. }
  71. ----
  72. // TEST[skip:TBD]
  73. The following example creates or updates an existing Search Application called `my-app`:
  74. [source,console]
  75. ----
  76. PUT _application/search_application/my-app
  77. {
  78. "indices": [ "index1", "index2", "index3" ],
  79. "template": {
  80. "script": {
  81. "source": {
  82. "query": {
  83. "query_string": {
  84. "query": "{{query_string}}",
  85. "default_field": "{{default_field}}"
  86. }
  87. }
  88. },
  89. "params": {
  90. "query_string": "*",
  91. "default_field": "*"
  92. }
  93. }
  94. }
  95. }
  96. ----
  97. // TEST[skip:TBD]