put-enrich-policy.asciidoc 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[put-enrich-policy-api]]
  4. === Create enrich policy API
  5. ++++
  6. <titleabbrev>Create enrich policy</titleabbrev>
  7. ++++
  8. Creates an enrich policy.
  9. ////
  10. [source,console]
  11. ----
  12. PUT /users
  13. {
  14. "mappings": {
  15. "properties": {
  16. "email": { "type": "keyword" }
  17. }
  18. }
  19. }
  20. ----
  21. ////
  22. [source,console]
  23. ----
  24. PUT /_enrich/policy/my-policy
  25. {
  26. "match": {
  27. "indices": "users",
  28. "match_field": "email",
  29. "enrich_fields": ["first_name", "last_name", "city", "zip", "state"]
  30. }
  31. }
  32. ----
  33. // TEST[continued]
  34. ////
  35. [source,console]
  36. --------------------------------------------------
  37. DELETE /_enrich/policy/my-policy
  38. --------------------------------------------------
  39. // TEST[continued]
  40. ////
  41. [[put-enrich-policy-api-request]]
  42. ==== {api-request-title}
  43. `PUT /_enrich/policy/<enrich-policy>`
  44. [[put-enrich-policy-api-prereqs]]
  45. ==== {api-prereq-title}
  46. // tag::enrich-policy-api-prereqs[]
  47. If you use {es} {security-features}, you must have:
  48. * `read` index privileges for any indices used
  49. * The `enrich_user` <<built-in-roles,built-in role>>
  50. // end::enrich-policy-api-prereqs[]
  51. [[put-enrich-policy-api-desc]]
  52. ==== {api-description-title}
  53. Use the create or update enrich policy API to create a new
  54. <<enrich-policy,enrich policy>>.
  55. [WARNING]
  56. ====
  57. include::../../enrich.asciidoc[tag=update-enrich-policy]
  58. ====
  59. [[put-enrich-policy-api-path-params]]
  60. ==== {api-path-parms-title}
  61. `<enrich-policy>`::
  62. (Required, string)
  63. Name of the enrich policy to create or update.
  64. [role="child_attributes"]
  65. [[put-enrich-policy-api-request-body]]
  66. ==== {api-request-body-title}
  67. `<policy-type>`::
  68. (Required, object)
  69. Configures the enrich policy. The field key is the enrich policy type. Valid key
  70. values are:
  71. +
  72. --
  73. `geo_match`:::
  74. Matches enrich data to incoming documents based on a
  75. <<query-dsl-geo-shape-query,`geo_shape` query>>. For an example, see
  76. <<geo-match-enrich-policy-type>>.
  77. `match`:::
  78. Matches enrich data to incoming documents based on a
  79. <<query-dsl-term-query,`term` query>>. For an example, see
  80. <<match-enrich-policy-type>>.
  81. --
  82. +
  83. .Properties of `<policy-type>`
  84. [%collapsible%open]
  85. ====
  86. `indices`::
  87. (Required, String or array of strings)
  88. One or more source indices used to create the enrich index.
  89. +
  90. If multiple indices are specified, they must share a common `match_field`.
  91. `match_field`::
  92. (Required, string)
  93. Field in source indices used to match incoming documents.
  94. `enrich_fields`::
  95. (Required, Array of strings)
  96. Fields to add to matching incoming documents. These fields must be present in
  97. the source indices.
  98. `query`::
  99. (Optional, <<query-dsl,Query DSL query object>>)
  100. Query used to filter documents in the enrich index. The policy only uses
  101. documents matching this query to enrich incoming documents. Defaults to a
  102. <<query-dsl-match-all-query,`match_all`>> query.
  103. ====