In addition to being able to index and replace documents, we can also update documents. Note though that Elasticsearch does not actually do in-place updates under the hood. Whenever we do an update, Elasticsearch deletes the old document and then indexes a new document with the update applied to it in one shot.

除了能够索引和替换文档,我们还可以更新文档。请注意,Elasticsearch实际上并没有在内部进行就地更新。每当我们进行更新时,Elasticsearch都会删除旧文档,然后一次性对应用了更新的新文档编制索引。
 
 This example shows how to update our previous document (ID of 1) by changing the name field to "Jane Doe":
此示例显示如何通过将名称字段更改为“Jane Doe”来更新以前的文档(ID为1):
curl -X POST "localhost:9200/customer/_doc/1/_update?pretty" -H 'Content-Type: application/json' -d'
{
"doc": { "name": "Jane Doe" }
}
'

This example shows how to update our previous document (ID of 1) by changing the name field to "Jane Doe" and at the same time add an age field to it:

此示例显示如何通过将名称字段更改为“Jane Doe”来更新我们以前的文档(ID为1),同时向其添加年龄字段:
 
curl -X POST "localhost:9200/customer/_doc/1/_update?pretty" -H 'Content-Type: application/json' -d'
{
"doc": { "name": "Jane Doe", "age": }
}
'

Updates can also be performed by using simple scripts. This example uses a script to increment the age by 5:

也可以使用简单脚本执行更新。此示例使用脚本将年龄增加5:
 
curl -X POST "localhost:9200/customer/_doc/1/_update?pretty" -H 'Content-Type: application/json' -d'
{
"script" : "ctx._source.doc.age += 5"
}
'

In the above example, ctx._source refers to the current source document that is about to be updated.

在上面的示例中,ctx._source指的是即将更新的当前源文档。
 
Elasticsearch provides the ability to update multiple documents given a query condition (like an SQL UPDATE-WHERE statement). See docs-update-by-query API
Elasticsearch提供了在给定查询条件(如SQL UPDATE-WHERE语句)的情况下更新多个文档的功能。请参阅docs-update-by-query API
 
 
 

(十一)Updating Documents的更多相关文章

  1. MongoDB - MongoDB CRUD Operations, Update Documents

    Update Methods MongoDB provides the following methods for updating documents in a collection: Method ...

  2. AsciiDoc

    AsciiDoc Text based document generation AsciiDoc Home Page Table of Contents Introduction Overview a ...

  3. 翻译【ElasticSearch Server】第一章:开始使用ElasticSearch集群(7)

    检索文档(Retrieving documents) 我们已经有文档存储在我们的实例.现在,让我们尝试检索它们: curl -XGET http://localhost:9200/blog/artic ...

  4. Java MongoDB Driver 3.x - Quick Start

    Maven Dependency: <dependency> <groupId>org.mongodb</groupId> <artifactId>mo ...

  5. lucene原理及源码解析--核心类

    马云说:大家还没搞清PC时代的时候,移动互联网来了,还没搞清移动互联网的时候,大数据时代来了. 然而,我看到的是:在PC时代搞PC的,移动互联网时代搞移动互联网的,大数据时代搞大数据的,都是同一伙儿人 ...

  6. elasticsearch6.7 01.入门指南(3)

    4.Modifying Your Data(修改数据) Elasticsearch 提供了近实时的操纵数据和搜索的能力.默认情况下,从索引/更新/删除数据到在搜索结果中显示数据会有 1 秒的延迟(刷新 ...

  7. Elasticsearch-->Get Started-->Modifying Your Data

    https://www.elastic.co/guide/en/elasticsearch/reference/current/getting-started-modify-data.html Mod ...

  8. lucene源码分析(2)读取过程实例

    1.官方提供的代码demo Analyzer analyzer = new StandardAnalyzer(); // Store the index in memory: Directory di ...

  9. windows系统中 利用kibana创建elasticsearch索引等操作

    elasticsearch之借用kibana平台创建索引 1.安装好kibana平台 确保kibana以及elasticsearch正常运行 2.打开kibana平台在Dev Tools 3.创建一个 ...

随机推荐

  1. HBase查询优化

    1.概述 HBase是一个实时的非关系型数据库,用来存储海量数据.但是,在实际使用场景中,在使用HBase API查询HBase中的数据时,有时会发现数据查询会很慢.本篇博客将从客户端优化和服务端优化 ...

  2. DocX开源WORD操作组件的学习系列三

    DocX学习系列 DocX开源WORD操作组件的学习系列一 : http://www.cnblogs.com/zhaojiedi1992/p/zhaojiedi_sharp_001_docx1.htm ...

  3. ubuntu 15.10 设置静态ip 分配固定ip 设置dns 设置网关 命令行配置ip 固定ip不生效怎么办

    要用到的文件: 配置接口信息 /etc/network/interfaces 配置内容: auto eth0 iface eth0 inet static address 192.168.216.18 ...

  4. Spring Boot (八)MyBatis + Docker + MongoDB 4.x

    一.MongoDB简介 1.1 MongoDB介绍 MongoDB是一个强大.灵活,且易于扩展的通用型数据库.MongoDB是C++编写的文档型数据库,有着丰富的关系型数据库的功能,并在4.0之后添加 ...

  5. 使用开源项目Alipay.AopSdk.Core完成支付宝网页登录

    核心方法: public IActionResult UserInfoCallBackAli() { var alipayClient = new DefaultAopClient(ConfigAli ...

  6. Python使用WMI模块获取Windows系统的硬件信息,并使用pyinstaller库编译打包成exe的可执行文件

    由于公司现阶段大多数应用软件都是基于Windows系统开发和部署,很多软件安装部署都是在windows server 2012.windows server 2008之类的服务器上,部门同事每次测试一 ...

  7. javascript基础修炼(9)——MVVM中双向数据绑定的基本原理

    开发者的javascript造诣取决于对[动态]和[异步]这两个词的理解水平. 一. 概述 1.1 MVVM模型 MVVM模型是前端单页面应用中非常重要的模型之一,也是Single Page Appl ...

  8. 用C#写的一个OA类的APP, ios、Android都能跑,有源代码

    这是一个用C#写的OA类APP,功能包含请假.报销.部门管理.签到.IM.文件上传等功能 话不多说,先看视频 视频地址:http://v.youku.com/v_show/id_XMzUwMjQ1Mz ...

  9. [Go] golang连接redis测试

    go-redis的使用1.下载代码到GOPATH环境变量指定的目录比如我的是进入目录D:\golang\code\src\github.com\go-redis , 执行git clone https ...

  10. vue从入门到进阶:Vuex状态管理(十)

    Vuex 是一个专为 Vue.js 应用程序开发的状态管理模式.它采用集中式存储管理应用的所有组件的状态,并以相应的规则保证状态以一种可预测的方式发生变化. 在 Vue 之后引入 vuex 会进行自动 ...