Fix the ingest attachment array examples
Fix up the ingest attachment array handling example so they are full examples and validated by the build system correctly.
This commit is contained in:
parent
e3eb363882
commit
b100f18505
|
@ -131,6 +131,7 @@ For example, given the following source:
|
|||
]
|
||||
}
|
||||
--------------------------------------------------
|
||||
// NOTCONSOLE
|
||||
|
||||
In this case, we want to process the data field in each element
|
||||
of the attachments field and insert
|
||||
|
@ -139,7 +140,11 @@ processor is used:
|
|||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
PUT _ingest/pipeline/attachment
|
||||
{
|
||||
"description" : "Extract attachment information from arrays",
|
||||
"processors" : [
|
||||
{
|
||||
"foreach": {
|
||||
"field": "attachments",
|
||||
"processor": {
|
||||
|
@ -149,8 +154,64 @@ processor is used:
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
PUT my_index/my_type/my_id?pipeline=attachment
|
||||
{
|
||||
"attachments" : [
|
||||
{
|
||||
"filename" : "ipsum.txt",
|
||||
"data" : "dGhpcyBpcwpqdXN0IHNvbWUgdGV4dAo="
|
||||
},
|
||||
{
|
||||
"filename" : "test.txt",
|
||||
"data" : "VGhpcyBpcyBhIHRlc3QK"
|
||||
}
|
||||
]
|
||||
}
|
||||
GET my_index/my_type/my_id
|
||||
--------------------------------------------------
|
||||
// CONSOLE
|
||||
|
||||
Returns this:
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
{
|
||||
"_index" : "my_index",
|
||||
"_type" : "my_type",
|
||||
"_id" : "my_id",
|
||||
"_version" : 1,
|
||||
"found" : true,
|
||||
"_source" : {
|
||||
"attachments" : [
|
||||
{
|
||||
"filename" : "ipsum.txt",
|
||||
"data" : "dGhpcyBpcwpqdXN0IHNvbWUgdGV4dAo=",
|
||||
"attachment" : {
|
||||
"content_type" : "text/plain; charset=ISO-8859-1",
|
||||
"language" : "en",
|
||||
"content" : "this is\njust some text",
|
||||
"content_length" : 24
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename" : "test.txt",
|
||||
"data" : "VGhpcyBpcyBhIHRlc3QK",
|
||||
"attachment" : {
|
||||
"content_type" : "text/plain; charset=ISO-8859-1",
|
||||
"language" : "en",
|
||||
"content" : "This is a test",
|
||||
"content_length" : 16
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
--------------------------------------------------
|
||||
// TESTRESPONSE
|
||||
|
||||
|
||||
Note that the `target_field` needs to be set, otherwise the
|
||||
default value is used which is a top level field `attachment`. The
|
||||
properties on this top level field will contain the value of the
|
||||
|
|
Loading…
Reference in New Issue