put-enrich-policy.asciidoc 2.9 KB

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