put-dfanalytics.asciidoc 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. [role="xpack"]
  2. [testenv="platinum"]
  3. [[put-dfanalytics]]
  4. === Create {dfanalytics-jobs} API
  5. [subs="attributes"]
  6. ++++
  7. <titleabbrev>Create {dfanalytics-jobs}</titleabbrev>
  8. ++++
  9. Instantiates a {dfanalytics-job}.
  10. experimental[]
  11. [[ml-put-dfanalytics-request]]
  12. ==== {api-request-title}
  13. `PUT _ml/data_frame/analytics/<data_frame_analytics_id>`
  14. [[ml-put-dfanalytics-prereq]]
  15. ==== {api-prereq-title}
  16. * You must have `machine_learning_admin` built-in role to use this API. You must
  17. also have `read` and `view_index_metadata` privileges on the source index and
  18. `read`, `create_index`, and `index` privileges on the destination index. For
  19. more information, see {stack-ov}/security-privileges.html[Security privileges]
  20. and {stack-ov}/built-in-roles.html[Built-in roles].
  21. [[ml-put-dfanalytics-desc]]
  22. ==== {api-description-title}
  23. This API creates a {dfanalytics-job} that performs an analysis on the source
  24. index and stores the outcome in a destination index.
  25. The destination index will be automatically created if it does not exist. The
  26. `index.number_of_shards` and `index.number_of_replicas` settings of the source
  27. index will be copied over the destination index. When the source index matches
  28. multiple indices, these settings will be set to the maximum values found in the
  29. source indices.
  30. The mappings of the source indices are also attempted to be copied over
  31. to the destination index, however, if the mappings of any of the fields don't
  32. match among the source indices, the attempt will fail with an error message.
  33. If the destination index already exists, then it will be use as is. This makes
  34. it possible to set up the destination index in advance with custom settings
  35. and mappings.
  36. [[ml-put-dfanalytics-path-params]]
  37. ==== {api-path-parms-title}
  38. `<data_frame_analytics_id>`::
  39. (Required, string) A numerical character string that uniquely identifies the
  40. {dfanalytics-job}. This identifier can contain lowercase alphanumeric
  41. characters (a-z and 0-9), hyphens, and underscores. It must start and end with
  42. alphanumeric characters.
  43. [[ml-put-dfanalytics-request-body]]
  44. ==== {api-request-body-title}
  45. `analysis`::
  46. (Required, object) Defines the type of {dfanalytics} you want to perform on your source
  47. index. For example: `outlier_detection`. See <<dfanalytics-types>>.
  48. `analyzed_fields`::
  49. (Optional, object) You can specify both `includes` and/or `excludes` patterns.
  50. If `analyzed_fields` is not set, only the relevant fields will be included.
  51. For example, all the numeric fields for {oldetection}.
  52. `analyzed_fields.includes`:::
  53. (Optional, array) An array of strings that defines the fields that will be
  54. included in the analysis.
  55. `analyzed_fields.excludes`:::
  56. (Optional, array) An array of strings that defines the fields that will be
  57. excluded from the analysis.
  58. `description`::
  59. (Optional, string) A description of the job.
  60. `dest`::
  61. (Required, object) The destination configuration, consisting of `index` and
  62. optionally `results_field` (`ml` by default).
  63. `index`:::
  64. (Required, string) Defines the _destination index_ to store the results of
  65. the {dfanalytics-job}.
  66. `results_field`:::
  67. (Optional, string) Defines the name of the field in which to store the
  68. results of the analysis. Default to `ml`.
  69. `model_memory_limit`::
  70. (Optional, string) The approximate maximum amount of memory resources that are
  71. permitted for analytical processing. The default value for {dfanalytics-jobs}
  72. is `1gb`. If your `elasticsearch.yml` file contains an
  73. `xpack.ml.max_model_memory_limit` setting, an error occurs when you try to
  74. create {dfanalytics-jobs} that have `model_memory_limit` values greater than
  75. that setting. For more information, see <<ml-settings>>.
  76. `source`::
  77. (Required, object) The source configuration, consisting of `index` and
  78. optionally a `query`.
  79. `index`:::
  80. (Required, string or array) Index or indices on which to perform the
  81. analysis. It can be a single index or index pattern as well as an array of
  82. indices or patterns.
  83. `query`:::
  84. (Optional, object) The {es} query domain-specific language
  85. (<<query-dsl,DSL>>). This value corresponds to the query object in an {es}
  86. search POST body. All the options that are supported by {es} can be used,
  87. as this object is passed verbatim to {es}. By default, this property has
  88. the following value: `{"match_all": {}}`.
  89. [[ml-put-dfanalytics-example]]
  90. ==== {api-examples-title}
  91. The following example creates the `loganalytics` {dfanalytics-job}, the analysis
  92. type is `outlier_detection`:
  93. [source,console]
  94. --------------------------------------------------
  95. PUT _ml/data_frame/analytics/loganalytics
  96. {
  97. "description": "Outlier detection on log data",
  98. "source": {
  99. "index": "logdata"
  100. },
  101. "dest": {
  102. "index": "logdata_out"
  103. },
  104. "analysis": {
  105. "outlier_detection": {
  106. }
  107. }
  108. }
  109. --------------------------------------------------
  110. // TEST[setup:setup_logdata]
  111. The API returns the following result:
  112. [source,console-result]
  113. ----
  114. {
  115. "id": "loganalytics",
  116. "description": "Outlier detection on log data",
  117. "source": {
  118. "index": ["logdata"],
  119. "query": {
  120. "match_all": {}
  121. }
  122. },
  123. "dest": {
  124. "index": "logdata_out",
  125. "results_field": "ml"
  126. },
  127. "analysis": {
  128. "outlier_detection": {}
  129. },
  130. "model_memory_limit": "1gb",
  131. "create_time" : 1562265491319,
  132. "version" : "8.0.0"
  133. }
  134. ----
  135. // TESTRESPONSE[s/1562265491319/$body.$_path/]
  136. // TESTRESPONSE[s/"version": "8.0.0"/"version": $body.version/]