version : 7.5
Using JS API but same with REST API
making an update like :
{
index : "myindex",
id : pid,
refresh : true,
body : {
"script" : {
"source" : " ctx._source.Histo.add(ctx._source.Actual); ctx._source.Actual = params;",
"params" : data
}
}
}
Actual is an object like
{
name (copy_to searchField),
email (copy_to searchField),
searchField (type text && store)
}.
Histo is a nested object ( array of objects like the Actual one).
The update script add the Actual object to the Histo nested array.
Everything is fine. I get a good result for a query like ... match { Actual.searchField : "new name is John" } ... return this :
{
Actual: {
name : "new name is John",
email : "new email" },
Histo : [
{
name : "my name is Peter",
email : "previous name"
} ,
{
name : "my veru first name was Kank",
email : "previous previous name"
}
]
}
That's good, but a query like .... match : { Histo.searchField : "my name is Peter" } return nothing.
The Histo.searchField is not copied from the Actual object ?
Any solution ?
Thank you