mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-09 14:34:43 +00:00
Currently the policy config is placed directly in the json object of the toplevel `policies` array field. For example: ``` { "policies": [ { "match": { "name" : "my-policy", "indices" : ["users"], "match_field" : "email", "enrich_fields" : [ "first_name", "last_name", "city", "zip", "state" ] } } ] } ``` This change adds a `config` field in each policy json object: ``` { "policies": [ { "config": { "match": { "name" : "my-policy", "indices" : ["users"], "match_field" : "email", "enrich_fields" : [ "first_name", "last_name", "city", "zip", "state" ] } } } ] } ``` This allows us in the future to add other information about policies in the get policy api response. The UI will consume this API to build an overview of all policies. The UI may in the future include additional information about a policy and the plan is to include that in the get policy api, so that this information can be gathered in a single api call. An example of the information that is likely to be added is: * Last policy execution time * The status of a policy (executing, executed, unexecuted) * Information about the last failure if exists
226 lines
5.1 KiB
Plaintext
226 lines
5.1 KiB
Plaintext
[role="xpack"]
|
|
[testenv="basic"]
|
|
[[get-enrich-policy-api]]
|
|
=== Get enrich policy API
|
|
++++
|
|
<titleabbrev>Get enrich policy</titleabbrev>
|
|
++++
|
|
|
|
Returns information about an enrich policy.
|
|
|
|
////
|
|
[source,console]
|
|
----
|
|
PUT /users
|
|
|
|
PUT /_enrich/policy/my-policy
|
|
{
|
|
"match": {
|
|
"indices": "users",
|
|
"match_field": "email",
|
|
"enrich_fields": ["first_name", "last_name", "city", "zip", "state"]
|
|
}
|
|
}
|
|
|
|
PUT /_enrich/policy/other-policy
|
|
{
|
|
"match": {
|
|
"indices": "users",
|
|
"match_field": "email",
|
|
"enrich_fields": ["first_name", "last_name", "city", "zip", "state"]
|
|
}
|
|
}
|
|
----
|
|
////
|
|
|
|
[source,console]
|
|
--------------------------------------------------
|
|
GET /_enrich/policy/my-policy
|
|
--------------------------------------------------
|
|
// TEST[continued]
|
|
|
|
|
|
[[get-enrich-policy-api-request]]
|
|
==== {api-request-title}
|
|
|
|
`GET /_enrich/policy/<enrich-policy>`
|
|
|
|
`GET /_enrich/policy`
|
|
|
|
`GET /_enrich/policy1,policy2`
|
|
|
|
|
|
[[get-enrich-policy-api-prereqs]]
|
|
==== {api-prereq-title}
|
|
|
|
include::put-enrich-policy.asciidoc[tag=enrich-policy-api-prereqs]
|
|
|
|
|
|
[[get-enrich-policy-api-path-params]]
|
|
==== {api-path-parms-title}
|
|
|
|
`<enrich-policy>`::
|
|
+
|
|
--
|
|
(Optional, string)
|
|
Comma-separated list of enrich policy names
|
|
used to limit the request.
|
|
|
|
To return information for all enrich policies,
|
|
omit this parameter.
|
|
--
|
|
|
|
|
|
[[get-enrich-policy-api-example]]
|
|
==== {api-examples-title}
|
|
|
|
|
|
[[get-enrich-policy-api-single-ex]]
|
|
===== Get a single policy
|
|
|
|
[source,console]
|
|
--------------------------------------------------
|
|
GET /_enrich/policy/my-policy
|
|
--------------------------------------------------
|
|
// TEST[continued]
|
|
|
|
The API returns the following response:
|
|
|
|
[source,console-result]
|
|
--------------------------------------------------
|
|
{
|
|
"policies": [
|
|
{
|
|
"config": {
|
|
"match": {
|
|
"name" : "my-policy",
|
|
"indices" : ["users"],
|
|
"match_field" : "email",
|
|
"enrich_fields" : [
|
|
"first_name",
|
|
"last_name",
|
|
"city",
|
|
"zip",
|
|
"state"
|
|
]
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
--------------------------------------------------
|
|
|
|
|
|
[[get-enrich-policy-api-commas-ex]]
|
|
===== Get multiple policies
|
|
|
|
[source,console]
|
|
--------------------------------------------------
|
|
GET /_enrich/policy/my-policy,other-policy
|
|
--------------------------------------------------
|
|
// TEST[continued]
|
|
|
|
The API returns the following response:
|
|
|
|
[source,js]
|
|
--------------------------------------------------
|
|
{
|
|
"policies": [
|
|
{
|
|
"config": {
|
|
"match": {
|
|
"name" : "my-policy",
|
|
"indices" : ["users"],
|
|
"match_field" : "email",
|
|
"enrich_fields" : [
|
|
"first_name",
|
|
"last_name",
|
|
"city",
|
|
"zip",
|
|
"state"
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"config": {
|
|
"match": {
|
|
"name" : "other-policy",
|
|
"indices" : ["users"],
|
|
"match_field" : "email",
|
|
"enrich_fields" : [
|
|
"first_name",
|
|
"last_name",
|
|
"city",
|
|
"zip",
|
|
"state"
|
|
]
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
--------------------------------------------------
|
|
// TESTRESPONSE
|
|
|
|
|
|
[[get-enrich-policy-api-all-ex]]
|
|
===== Get all policies
|
|
|
|
[source,console]
|
|
--------------------------------------------------
|
|
GET /_enrich/policy
|
|
--------------------------------------------------
|
|
// TEST[continued]
|
|
|
|
The API returns the following response:
|
|
|
|
[source,console-result]
|
|
--------------------------------------------------
|
|
{
|
|
"policies": [
|
|
{
|
|
"config": {
|
|
"match": {
|
|
"name" : "my-policy",
|
|
"indices" : ["users"],
|
|
"match_field" : "email",
|
|
"enrich_fields" : [
|
|
"first_name",
|
|
"last_name",
|
|
"city",
|
|
"zip",
|
|
"state"
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"config": {
|
|
"match": {
|
|
"name" : "other-policy",
|
|
"indices" : ["users"],
|
|
"match_field" : "email",
|
|
"enrich_fields" : [
|
|
"first_name",
|
|
"last_name",
|
|
"city",
|
|
"zip",
|
|
"state"
|
|
]
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
--------------------------------------------------
|
|
|
|
////
|
|
[source,console]
|
|
--------------------------------------------------
|
|
DELETE /_enrich/policy/my-policy
|
|
DELETE /_enrich/policy/other-policy
|
|
--------------------------------------------------
|
|
// TEST[continued]
|
|
////
|