post-data.asciidoc 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. --
  2. :api: post-data
  3. :request: PostDataRequest
  4. :response: PostDataResponse
  5. --
  6. [role="xpack"]
  7. [id="{upid}-{api}"]
  8. === Post Data API
  9. The Post Data API provides the ability to post data to an open
  10. {ml} job in the cluster.
  11. It accepts a +{request}+ object and responds
  12. with a +{response}+ object.
  13. [id="{upid}-{api}-request"]
  14. ==== Post Data Request
  15. A +{request}+ object gets created with an existing non-null `jobId`
  16. and the `XContentType` being sent. Individual docs can be added
  17. incrementally via the `PostDataRequest.JsonBuilder#addDoc` method.
  18. These are then serialized and sent in bulk when passed to the +{request}+.
  19. Alternatively, the serialized bulk content can be set manually, along with its `XContentType`
  20. through one of the other +{request}+ constructors.
  21. Only `XContentType.JSON` and `XContentType.SMILE` are supported.
  22. ["source","java",subs="attributes,callouts,macros"]
  23. --------------------------------------------------
  24. include-tagged::{doc-tests-file}[{api}-request]
  25. --------------------------------------------------
  26. <1> Create a new `PostDataRequest.JsonBuilder` object for incrementally adding documents
  27. <2> Add a new document as a `Map<String, Object>` object
  28. <3> Add a new document as a serialized JSON formatted String.
  29. <4> Constructing a new request referencing an opened `jobId`, and a JsonBuilder
  30. ==== Optional Arguments
  31. The following arguments are optional.
  32. ["source","java",subs="attributes,callouts,macros"]
  33. --------------------------------------------------
  34. include-tagged::{doc-tests-file}[{api}-request-options]
  35. --------------------------------------------------
  36. <1> Set the start of the bucket resetting time
  37. <2> Set the end of the bucket resetting time
  38. include::../execution.asciidoc[]
  39. [id="{upid}-{api}-response"]
  40. ==== Post Data Response
  41. A +{response}+ contains current data processing statistics.
  42. ["source","java",subs="attributes,callouts,macros"]
  43. --------------------------------------------------
  44. include-tagged::{doc-tests-file}[{api}-response]
  45. --------------------------------------------------
  46. <1> `getDataCounts()` a `DataCounts` object containing the current
  47. data processing counts.