LoginSignup
0
1

More than 3 years have passed since last update.

Elasticsearchの設定色々メモ

Posted at

Elasticsearch設定などのリクエスト

# my_indexはindex

# 全件検索
curl  -H 'Content-Type:application/json' -XPOST 'localhost:9200/my_index/_search'

# 全件削除
curl  -H 'Content-Type:application/json' -XPOST 'localhost:9200/my_index/_delete_by_query' -d '{"query":{"match_all":{}}}'

# ESの状態表示
curl 'localhost:9200/_cat/indices?v'

# indexの削除
curl  -H 'Content-Type:application/json' -XPUT 'localhost:9200/my_index/_mapping' -d @tests/local_es/mapping.json

# index作成
curl  -H 'Content-Type:application/json' -XPUT 'localhost:9200/my_index'

# analyzerを登録 (indexを作成と同じことをやるので、すでに存在しているインデックスがあるとプットできない)
curl -H "Content-type:application/json" -XPUT 'localhost:9200/my_index' -d @tests/local_es/analyzer/my_kuromoji_analyzer.json

# mapping(スキーマ)の確認
curl -H 'Content-Type:application/json' -XGET 'localhost:9200/my_index_mapping'
## memo 実際のcasesの方はcontentなどにanalyzerキーで my_kuromoji_analyzerというのがついていたがローカルでは使えなかったので、mapping.jsonからは消してある

# mapping(スキーマの流し込み)
curl -H 'Content-Type:application/json' -XPUT 'localhost:9200/my_index/_mapping' -d @tests/local_es/mapping.json

# エイリアスの設定方法
curl -H 'Content-Type:application/json' -XPOST 'localhost:9200/_aliases' -d '{"actions":[{"add":{"index":"my_index", "alias":"my_alias"}}]}

# 複数流し込む(prettyは応答を改行して表示)
curl -H 'Content-Type:application/json' -XPUT 'localhost:9200/_bulk' --data-binary '@tests/local_es/test_input.json' -o /dev/null

参考

エイリアスの設定
Elasticsearch 日本語で全文検索 その2
Analyzerの設定
Elasticsearchへの日本語データ投入と検索の方法(初級)
Elasticsearchの確認系コマンド6つ

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