Let’s now put something into our customer index. We’ll index a simple customer document into the customer index, with an ID of 1 as follows:

现在让我们在客户索引中加入一些内容。我们将一个简单的客户文档索引到客户索引中,ID为1,如下所示:
curl -X PUT "localhost:9200/customer/_doc/1?pretty" -H 'Content-Type: application/json' -d'
{
"name": "John Doe"
}
'
 And the response:
{
"_index" : "customer",
"_type" : "_doc",
"_id" : "",
"_version" : ,
"result" : "created",
"_shards" : {
"total" : ,
"successful" : ,
"failed" :
},
"_seq_no" : ,
"_primary_term" :
}

From the above, we can see that a new customer document was successfully created inside the customer index. The document also has an internal id of 1 which we specified at index time.

从上面可以看出,在客户索引中成功创建了一个新的客户文档。该文档的内部标识为1,我们在索引时指定。
 
It is important to note that Elasticsearch does not require you to explicitly create an index first before you can index documents into it. In the previous example, Elasticsearch will automatically create the customer index if it didn’t already exist beforehand.
值得注意的是,Elasticsearch在您将文档编入索引之前不需要先显式创建索引。在前面的示例中,如果客户索引事先尚未存在,则Elasticsearch将自动创建客户索引。
 
Let’s now retrieve that document that we just indexed:
我们现在检索刚刚编入索引的文档:
curl -X GET "localhost:9200/customer/_doc/1?pretty"

And the response:

{
"_index" : "customer",
"_type" : "_doc",
"_id" : "",
"_version" : ,
"found" : true,
"_source" : { "name": "John Doe" }
}

Nothing out of the ordinary here other than a field, found, stating that we found a document with the requested ID 1 and another field, _source, which returns the full JSON document that we indexed from the previous step.

除了字段之外,没有任何异常,发现,说明我们找到了一个具有请求ID 1的文档和另一个字段_source,它返回我们从上一步索引的完整JSON文档。
 

(八)Index and Query a Document的更多相关文章

  1. Learning Query and Document Similarities from Click-through Bipartite Graph with Metadata

    读了一篇paper,MSRA的Wei Wu的一篇<Learning Query and Document Similarities from Click-through Bipartite Gr ...

  2. Elasticsearch核心技术(2)--- 基本概念(Index、Type、Document、集群、节点、分片及副本、倒排索引)

    Elasticsearch核心技术(2)--- 基本概念 这篇博客讲到基本概念包括: Index.Type.Document.集群,节点,分片及副本,倒排索引. 一.Index.Type.Docume ...

  3. 【ElasticSearch】:索引Index、文档Document、字段Field

    因为从ElasticSearch6.X开始,官方准备废弃Type了.对应数据库,对ElasticSearch的理解如下: ElasticSearch 索引Index 文档Document 字段Fiel ...

  4. 【MonogDB】The description of index(二) Embedded and document Index

    In this blog, we will talk about another the index which was called "The embedded ". First ...

  5. Elasticsearch-->Get Started-->Exploring Your Cluster

    Version 直接对localhost:9200发出一个get请求 { "name": "WqeJVip", "cluster_name" ...

  6. ES Docs-2:Exploring ES cluster

    The REST API Now that we have our node (and cluster) up and running, the next step is to understand ...

  7. Elasticsearch 入门 - Exploring Your Cluster

    The REST API Cluster Health ( http://localhost:9200/ ) curl -X GET "localhost:9200/_cat/health? ...

  8. 2743711 - Possible Unexpected Results When Using Query With an ORDER BY Clause on a Rowstore Table With a Parallelized Search on a Cpbtree-Type Index

    2743711 - Possible Unexpected Results When Using Query With an ORDER BY Clause on a Rowstore Table W ...

  9. ElasticSearh更新nested字段(Array数组)。怎么根据查询条件(query)复制一个(index)到新的Index how to update by query a nested fields data for elasticsearch

    GET usernested/_search { "query": { "nested": { "path": "tags&quo ...

随机推荐

  1. 教你MySQL Binlog实用攻略

    本文由云+社区发表 1.概述 binlog是Mysql sever层维护的一种二进制日志,与innodb引擎中的redo/undo log是完全不同的日志:其主要是用来记录对mysql数据更新或潜在发 ...

  2. Docker系列02—LXC---Docker的“前身”

    本文收录在容器技术学习系列文章总目录 一.LXC介绍 1.Linux Container容器是一种内核虚拟化技术,可以提供轻量级的虚拟化,以便隔离进程和资源. 2.LXC为Linux Containe ...

  3. 痞子衡嵌入式:常用的数据差错控制技术(2)- 奇偶校验(Parity Check)

    大家好,我是痞子衡,是正经搞技术的痞子.今天痞子衡给大家讲的是嵌入式里数据差错控制技术-奇偶校验. 在系列第一篇文章里,痞子衡给大家介绍了最简单的校验法-重复校验,该校验法实现简单,检错纠错能力都还不 ...

  4. Spring之BeanFactory和FactoryBean接口的区别

    目录 一.BeanFactory接口 二.FactoryBean接口 1.简单实现 2.增强实现 3.FactoryBean的实际使用案例 三.总结 @   Spring框架中的BeanFactory ...

  5. JaveWeb学习之Servlet(二):ServletConfig和ServletContext

    原文同步发表至个人博客[夜月归途] 原文链接:http://www.guitu18.com/se/java/2018-07-26/20.html 作者:夜月归途 出处:http://www.guitu ...

  6. 权限管理系统之项目框架搭建并集成日志、mybatis和分页

    前一篇博客中使用LayUI实现了列表页面和编辑页面的显示交互,但列表页面table渲染的数据是固定数据,本篇博客主要是将固定数据变成数据库数据. 一.项目框架 首先要解决的是项目框架问题,搭建什么样的 ...

  7. Android开发——使用intent传递对象

    intent传递对象有两种方法: 方式一:Serializable 方式 方式二:Parcelable方式 在这里不多介绍了,这一篇就是快速上手使用教程,至于详细原理介绍的,请看这一篇http://w ...

  8. asp.net引用System.Speech实现语音提示

    using System; using System.Speech.Synthesis; namespace testvoice { class Program { static void Main( ...

  9. 关于我的博客(About My Blogs)

    本文算是第一篇文章,记录工作/学习/生活中的觉得值得分享的东西 When,Where,Who,What,How,Why,尽可能每篇博文当作一个事件来描述. 也就是触发想写这篇文章的事件. 要坚持下来写 ...

  10. excel函数2

    1截取函数的应用 实例: 2.日期的年周月星期数据处理