I have two indices. index1
and index2
.
Let say each document in index1
owes fields
[ "host.name", "ip"]
And each document in index2
owes fields
[ "host.name", "software"]
index2
can contain multiple documents for different softwares with the same host.name
field.
What I want to archive is one unified document containing host.name
, ip
and an array of software
I had set up an enrichment policy + processor in pipeline, executed it and index a document via the pipeline. What I archived is document containing host.name
ip
and some random software
from index2
.
Here is my enrich policy setup:
PUT _enrich/policy/host-soft
{
"match": {
"indices" : ["index2"],
"match_field": "host.name",
"enrich_fields": [ "software" ]
}
}
POST _enrich/policy/host-soft/_execute
PUT _ingest/pipeline/host-soft
{
"description": "enrich data from index2",
"processors": [
{
"enrich": {
"policy_name": "host-soft",
"field": "host.name,
"target_field": "softwares"
}
}
]
}
PUT /index1/_doc/test1?pipeline=host-soft
{
"host": {
"name": "host1"
},
"ip": "127.0.0.1"
}
GET /index1/_doc/test1
result
{
"host": {
"name": "host1"
},
"ip": "127.0.0.1",
"softwares": {
"software": "soft3",
}
}
Desired document
{
"host": {
"name": "host1"
},
"ip": "127.0.0.1",
"softwares": [ "soft1", "soft2", "soft3", "soft4", "soft5" ]
}