elasticsearch如何更新文档?它会删除原始文件并创建新文件吗?我听说这就是 nosql 的更新方法。 elasticsearch 和其他任何 nosql 数据库一样吗?或者它将只替换/插入需要的字段?
最佳答案
例如,我正在运行 Elasticsearcherh 7.0.0。 首先,我创建了一个文档,
PUT/employee/_doc/1
{
"first_name" : "John",
"last_name" : "Snow",
"age" : 19,
"about" : "King in the north",
"sex" : "male"
}
然后我通过
更新了它POST/employee/_update/1/
{
"doc": {
"first_name" : "Aegon",
"last_name" : "Targaryen",
"skill": "fighting and leading"
}
}
最后,我得到了正确的结果
GET/employee/_doc/1
{
"_index" : "employee",
"_type" : "_doc",
"_id" : "1",
"_version" : 9,
"_seq_no" : 11,
"_primary_term" : 1,
"found" : true,
"_source" : {
"first_name" : "Aegon",
"last_name" : "Targaryen",
"age" : 19,
"about" : "King in the north",
"sex" : "male",
"skill" : "fighting and leading"
}
}
关于Elasticsearch - 如何更新文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45836188/