ES测试命令

目录

[TOC]

简单命令测试和展示es的功能

插入记录

1
2
3
4
5
6
7
8
9
10
11
curl  -H "Content-Type: application/json"  -XPUT 'http://localhost:9200/store/books/1' -d '{

"title": "Elasticsearch: The Definitive Guide",
"name" : {
"first" : "Zachary",
"last" : "Tong"
},
"publish_date":"2015-02-06",
"price":"49.99"

}'

在添加一个书的信息

1
2
3
4
5
6
7
8
9
curl  -H "Content-Type: application/json"  -XPUT 'http://elk1:9200/store/books/2' -d '{
"title": "Elasticsearch Blueprints",
"name" : {
"first" : "Vineeth",
"last" : "Mohan"
},
"publish_date":"2015-06-06",
"price":"35.99"
}'

通过ID获得文档信息

1
curl   -H "Content-Type: application/json"  -XGET 'http://elk1:9200/store/books/1'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
curl  -H "Content-Type: application/json"  -XGET 'http://elk1:9200/store/books/_search' -d '{
"query" : {

"filtered" : {
"query" : {
"match_all" : {}
},
"filter" : {
"term" : {
"price" : 35.99
}
}
}
}

}'

在浏览

1
2
3
4
5
6
7
8
9
10
11
curl -H "Content-Type: application/json"  -XPUT 'http://elk1:9200/store/books/1' -d '{

"title": "Elasticsearch: The Definitive Guide",
"name" : {
"first" : "Zachary",
"last" : "Tong"
},
"publish_date":"2015-02-06",
"price":"49.99"

}'
1
curl -H "Content-Type: application/json" -XPUT 'http://127.0.0.1:9200/kc22k2_test' -d
1
curl -XPUT elk1:9200/test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
curl -XGET 'http://elk1:9200/_cluster/state?pretty'
{
"error" : {

"root_cause" : [
{
"type" : "master_not_discovered_exception",
"reason" : null
}
],
"type" : "master_not_discovered_exception",
"reason" : null

},
"status" : 503
}
评论