开发者学堂课程【ElasticSearch 最新快速入门教程:创建索引库和索引_演示】学习笔记,与课程紧密联系,让用户快速学习知识。
课程地址:https://developer.aliyun.com/learning/course/642/detail/10606
创建索引库和索引_演示
首先创建,查看服务器反馈。
需求1:
使用 cur 创建一个名为 bigdata 的索引库。
[jerry@JANSON01 es]$ curl –XPUT
http://JANJSON01:9200/bigdata?pretty
'
{
"acknowledged" : true,
"shards_acknowledged" : true,
"index" : "bigdata"
需求二:
使用 curl 在名为 bigdata 的索引库下创建一个名为
product 的 type,且在该 type 下新增一条索引标志为1
的 document,该 document 的信息如下 :
{"name":"Hadoop"," author":"Dok cultting","last version":"
3.0.0"}
实操演示:
[jerry@JANSON01 es]$ curl -XPOST
http:/JANSON01:9200/bigdata/product/1' -H
'Content-Type:application/json' -d '{
>
"
name":"Hadoop",
> "author":"Doc Cultting",
> "last version":" 3.0.1"
反馈的结果是:
{"_ index":"bigdata"," type":" product"," id":" 1","
version":1,"result":" created"," shards":{"
total":2,"successful":1,"failed":
0
}," seq no":
0
," primary
term :1
需求3 :
使用 curl 在名为 bigdata 的索引库下创建一个名为 product 的
type,且在该 type 下新增一条使用默认索引标志的 document,该
document 的信息如下 :
{"name":"Spark"," author":
"
杰克逊"last version":" 2.4.5"}
实操演示:
jerry@JANSON01 es]$ curl -XPOST
'http://JANSON01:9200/bigdata/product?pretty' -H
'Content-Type:application/jison' -d '{
> "name":"Spark",
>”author":"杰克逊",
> "last _version":"2.3.4"
> }'
反馈的结果是:
"
_
index" : "bigdata",
"_type" : "product",
"
_
id" : "HM9rL2oB300nRXZV6BRB",
"
_
version" : 1,
"result" : "created",
"_shards" :{
"total" : 2,
"successful" : 1,
"failed" :0
},
"_seq_no":1,
"
_
primary
_
term": 1