[role="xpack"]
[testenv="basic"]
[[execute-enrich-policy-api]]
=== Execute enrich policy API
++++
Execute enrich policy
++++
Executes an existing <>.
////
[source,console]
----
PUT /users/_doc/1?refresh
{
"email": "mardy.brown@asciidocsmith.com",
"first_name": "Mardy",
"last_name": "Brown",
"city": "New Orleans",
"county": "Orleans",
"state": "LA",
"zip": 70116,
"web": "mardy.asciidocsmith.com"
}
PUT /_enrich/policy/my-policy
{
"match": {
"indices": "users",
"match_field": "email",
"enrich_fields": ["first_name", "last_name", "city", "zip", "state"]
}
}
----
// TESTSETUP
////
[source,console]
--------------------------------------------------
PUT /_enrich/policy/my-policy/_execute
--------------------------------------------------
////
[source,console]
--------------------------------------------------
DELETE /_enrich/policy/my-policy
--------------------------------------------------
// TEST[continued]
////
[[execute-enrich-policy-api-request]]
==== {api-request-title}
`PUT /_enrich/policy//_execute`
`POST /_enrich/policy//_execute`
[[execute-enrich-policy-api-prereqs]]
==== {api-prereq-title}
include::put-enrich-policy.asciidoc[tag=enrich-policy-api-prereqs]
[[execute-enrich-policy-api-desc]]
==== {api-description-title}
Use the execute enrich policy API
to create the enrich index for an existing enrich policy.
// tag::execute-enrich-policy-def[]
The _enrich index_ contains documents from the policy's source indices.
Enrich indices always begin with `.enrich-*`,
are read-only,
and are <>.
[WARNING]
====
Enrich indices should be used by the <> only.
Avoid using enrich indices for other purposes.
====
// end::execute-enrich-policy-def[]
// tag::update-enrich-index[]
Once created, you cannot update
or index documents to an enrich index.
Instead, update your source indices
and <> the enrich policy again.
This creates a new enrich index from your updated source indices
and deletes the previous enrich index.
// end::update-enrich-index[]
Because this API request performs several operations,
it may take a while to return a response.
[[execute-enrich-policy-api-path-params]]
==== {api-path-parms-title}
``::
(Required, string)
Enrich policy to execute.
[[execute-enrich-policy-api-request-body]]
==== {api-request-body-title}
`wait_for_completion`::
(Required, boolean)
If `true`, the request blocks other enrich policy execution requests until
complete. Defaults to `true`.