0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Elasticsearchのよく使うコマンド集

Last updated at Posted at 2020-10-06

備忘録としてまとめます。

よく使うコマンド

インデックス一覧の確認

インデックス名や、インデックスの状態を確認することができる。

curl -XGET "$ELASTICSEARCH_URL/_cat/indices?v"

エイリアスの確認

curl "$ELASTICSEARCH_URL/_alias?pretty"

インデックスのマッピングの確認

curl "$ELASTICSEARCH_URL/$INDEX_NAME/_mapping?pretty"

ドキュメント一覧

インデックスに入っているドキュメントの一覧を確認することができる。

curl -XGET "$ELASTICSEARCH_URL/$INDEX_NAME/_search?pretty"

ドキュメント1件取得

インデックスにちゃんとドキュメントが入ったか確認することができる。

curl "$ELASTICSEARCH_URL/$INDEX_NAME/_search?pretty" -H "Content-type: application/json" -d '{"size":1}'

最新のドキュメント1件取得

timestampは特定フィールドに書き換えること

curl -X GET "$ELASTICSEARCH_URL/$INDEX_NAME/_search?pretty" -H "Content-Type: application/json" -d'
{
  "size": 1,
  "sort": [
    {
      "timestamp": {
        "order": "desc"
      }
    }
  ]
}'

ドキュメントの件数確認

curl -sS -XGET "$ELASTICSEARCH_URL/$INDEX_NAME/_count?pretty"

エイリアス確認

curl -XGET "$ELASTICSEARCH_URL/_aliases?pretty"

ESのクエリ実行

curl -XGET "$ELASTICSEARCH_URL/$INDEX_NAME/_search?pretty' -H "Content-Type: application/json" -d '{ESのクエリ}'

sample

curl -X GET "$ELASTICSEARCH_URL/$INDEX_NAME/_search?pretty" -H 'Content-Type: application/json' -d'
{
  "query": {
    "terms": {
      "id": ["1", "2", "3"]
    }
  }
}
'

参考

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?