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. linux文本处理三剑客的学习

    linux下有三个文本处理的神器.分别是grep,sed,awk.功能都是比较强大的. grep帮助: http://my-study-grep.readthedocs.io/en/latest/ s ...

  2. Alibaba Cluster Data 开放下载:270GB 数据揭秘你不知道的阿里巴巴数据中心

    打开一篇篇 IT 技术文章,你总能够看到“大规模”.“海量请求”这些字眼.如今,这些功能强大的互联网应用,都运行在大规模数据中心上,然而,对于大规模数据中心,你又了解多少呢?实际上,除了阅读一些科技文 ...

  3. mysqladmin实用工具

    mysqladmin命令行实用工具是命令行工具套件中的重量级工具.这个工具可以执行很多选项和工具(被称为命令). 因为这个实用工具是从命令行启动运行的,它使得管理员可以编写一系列操作脚本,这比直接运行 ...

  4. Kafka基础入门

    1. Kafka简介 Kafka是由Apache软件基金会开发的一个开源流处理平台,由Scala和Java编写.Kafka是一种高吞吐量的分布式发布订阅消息系统,它可以处理消费者规模的网站中的所有动作 ...

  5. 记一个常见的ms sql server中取第N条记录的方法

    前言 好好学习,天天向上. 正文 好像也是一个不难的问题,刚视频里看到的,就记一下吧. 下面是表中原始的数据结构,做了一个倒叙排序: select * from Employee order by S ...

  6. Springboot 系列(一)Spring Boot 入门篇

    注意:本 Spring Boot 系列文章基于 Spring Boot 版本 v2.1.1.RELEASE 进行学习分析,版本不同可能会有细微差别. 前言 由于 J2EE 的开发变得笨重,繁多的配置, ...

  7. static 静态与非静态的区别

    静态属性是共享一块内存空间.实例的是各自独享一块内存空间. 比如同一个name属性.如果是实例成员.那么你每创建了一个对象.赋给name值.假如创建了2个对象.第一个赋值张三.第2个赋值李四.它们就分 ...

  8. Hdu 3001 Travelling 状态DP

    题目大意 一次旅游,经过所有城市至少一次,并且任何一座城市访问的次数不能超过两次,求最小费用 每个城市最多访问两次,用状态0,1,2标识访问次数 把城市1~N的状态按照次序连接在一起,就组成了一个三进 ...

  9. localhost和127.0.01 区别

    笔者最近调试程序时遇到的一个问题,localhost不能访问但127.0.0.1可以访问. 一.原理 我估计大多数人都不会去想localhost到底与127.0.0.1有什么不同,就比如我,有时候用h ...

  10. 解决centos7.0安装mysql后出现access defind for user@'localhost'的错误

    在使用yum 安装完mariadb, mariadb-server, mariadb-devel后 1. rpm -qa | grep maria   查看maria相关库的是否在进程中 2. net ...