0
Ich habe eine Elasticsearch-DB und möchte Elemente (Strings) zu einem Array hinzufügen. Nach der Diskussion hier https://discuss.elastic.co/t/append-to-existing-field/16423/2 habe ich ein Spielzeug-Modell eingerichtet. I init mit:Elasticsearch, warum wird Element immer null hinzugefügt
curl -XPOST "http://localhost:9200/t/t/1/" -d'
{
"hobbies" : ["a", "b"]
}'
und das Update das Array mit
curl -XPOST "http://localhost:9200/t/t/1/_update" -d'
{
"script" : "ctx._source.hobbies.add(params.hobby)",
"params" : {
"hobby" : "c"
}
}'
Leider ist das aktualisierte Ergebnis immer "null" und nicht die "c":
curl -XGET 'http://localhost:9200/_search?q=_id:"1"&pretty'
{
"took" : 29,
"timed_out" : false,
"_shards" : {
"total" : 20,
"successful" : 20,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [
{
"_index" : "t",
"_type" : "t",
"_id" : "1",
"_score" : 1.0,
"_source" : {
"hobbies" : [
"a",
"b",
null,
null,
null
]
}
}
]
}
}
Was bin ich falsch machen?