LoginSignup
1
1

More than 5 years have passed since last update.

elasticsearch利用例 Kibanaにて

Last updated at Posted at 2018-08-10

POST

Curl

curl -XPOST "http://localhost:9200/product/default" -H 'Content-Type: application/json' -d'
{
"name": "processing event with logtash",
"instructor":{
"firstname":"Taro",
"lastname":"Yamada"
}
}'

kibana

POST /product/default
{
"name": "processing event with logtash",
"instructor":{
"firstname":"Taro",
"lastname":"Yamada"
}
}

Curl

curl -XPUT "http://localhost:9200/product/default/1" -H 'Content-Type: application/json' -d'
{
"name": "wonderful kibana",
"instructor":{
"firstname":"Taro",
"lastname":"Yamada"
}
}'

kibana

PUT /product/default/1
{
"name": "wonderful kibana",
"instructor":{
"firstname":"Taro",
"lastname":"Yamada"
}
}

GET

Curl

curl -XGET "http://localhost:9200/product/default/1"

kibana

GET /product/default/1

Update(doc property)

Curl

curl -XPOST "http://localhost:9200/product/default/1/_update" -H 'Content-Type: application/json' -d'

kibana

POST /product/default/1/_update
{
"doc":{ "price":99, "tags":["Elasticsearch"] }
}

Update(script property)

Curl

curl -XPOST "http://localhost:9200/product/default/1/_update" -H 'Content-Type: application/json' -d'
{
"script": "ctx._source.price += 10"
}'

kibana

POST /product/default/1/_update
{
"script": "ctx._source.price += 10"
}

Delete

Curl

curl -XDELETE "http://localhost:9200/product/default/1"

kibana

DELETE /product/default/1

Delete Query

Curl

curl -XPOST "http://localhost:9200/product/_delete_by_query" -H 'Content-Type: application/json' -d'
{
"query":{
"match":{
"name": "wonderful kibana"
}
}
}'

kibana

POST /product/_delete_by_query
{
"query":{
"match":{
"name": "wonderful kibana"
}
}
}

JSONデータをCurlで登録

事前にjson形式のファイルを、curl実行するディレクトリに置く
スクリーンショット 2018-08-11 12.55.53.png

実行

$ curl -H "Content-Type: application/json" -XPOST "http://localhost:9200/product/default/_bulk?pretty" --data-binary "@products-bulk.json"

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1