What is the correct syntax for the enrich processor to access field for enrichment for an object within an array?
This works to get access to field in single object, as shown in the example provided. This is what I am starting from.
POLICY DEFINITION:
PUT /_enrich/policy/country_enrichment_v1
{
"match": {
"indices": [
"country_enrichment_test"
],
"match_field": "countryName",
"enrich_fields": [
"continent",
"region_un",
"subregion",
"region_wb"
]
}
}
EXECUTE POLICY and
DEFINE INGEST PIPELINE WITH ENRICH PROCESSOR
PUT _ingest/pipeline/enrich_country_data_v0
{
"processors": [
{
"enrich": {
"policy_name": "country_enrichment_v1",
"field": "nationOfResidence.name",
"target_field": "nationOfResidenceEnriched"
}
}
]
}
INSERT RECORD:
PUT /reports_enriched_v0/_doc/2?pipeline=enrich_country_data_v0
{
"nationOfResidence": {
"name": "Singapore"
}
}
*** Note actual object has additional fields ***
RESULT:
{
"_index" : "reports_enriched_v0",
"_type" : "_doc",
"_id" : "2",
"_version" : 1,
"_seq_no" : 1,
"_primary_term" : 1,
"found" : true,
"_source" : {
"nationOfResidence" : {
"name" : "Singapore"
},
"nationOfResidenceEnriched" : {
"continent" : "Asia",
"subregion" : "Eastern Asia",
"region_wb" : "Eastern Asia",
"region_un" : "Asia",
"countryName" : "Singapore"
}
}
}
==============================================================
I want to do the same for same object field that is within an array.
I assume I want to wrap the Enrich processor within a Foreach processor?
If so , what is the correct syntax to permit the enrich processor to access the match field in the object?
DEFINE INGEST PIPELINE WITH ENRICH PROCESSOR
PUT _ingest/pipeline/enrich_country_data_v1
{
"processors": [
{
"enrich": {
"policy_name": "country_enrichment_v1",
"field": "nationOfResidence.name",
"target_field": "nationOfResidenceEnriched"
}
},
{
"foreach": {
"field": "nationsTravelled",
"processor": {
"enrich": {
"policy_name": "country_enrichment_v1",
"field": "name", <<== WHAT SHOULD GO HERE? I have tried a number of things but no success yet
"target_field": "nationsTravelledEnriched"
}
}
}
}
]
}
INSERT RECORD WITH LIST OBJECTS:
PUT /reports_enriched_v0/_doc/2?pipeline=enrich_country_data_v1
{
"nationOfResidence": {
"name": "Singapore"
},
"nationsTravelled": [
{
"name": "Japan",
...
},
{
"name": "Germany",
....
}
]
}
*** NOTE: Actual objects have additional fields defined ***
Recommendations? Thank you.