# elastic-search マイチートシート ###### tags: `elastic-search` - lasticsearchの情報の確認 ```curl localhost:9200/_nodes/stats?pretty``` - プラグイン/モジュール一覧 ```curl http://localhost:9200/_nodes/plugins?pretty``` - インデックス一覧 ```curl http://localhost:9200/_aliases?pretty``` - インデックスのマッピング確認 ```curl http://localhost:9200/<indexname>/_mapping?pretty``` - インデックス存在確認 ```curl -XGET localhost:9200/index_name/_mapping?pretty=true``` - インデックス削除 ```curl -XDELETE localhost:9200/index_name?pretty=true``` - データ確認 ```curl http://localhost:9200/<indexname>/_search?pretty``` ## termとmatchのざっくりとしたちがい termは大文字小文字分ける matchはわけない [詳しくはここ](https://medium.com/veltra-engineering/elasticsearch-fulltext-termlevel-772e8a9152b1) terms クエリは Term level queries match クエリは Full text queries Full text queries は言語処理される。Term level queries は言語処理されない。 ## dockerで立てたelasticsearchが落ちた場合 1. ```docker inspect```で原因究明 2. コンテナに入って/var/log/elasticsearchを見てみる 3. elasticsearchは大量のファイルディスクリプタを消費するので、ファイルディスクリプタ数の上限を指定してみる。 ``` docker run -m 1250m --ulimit nofile=32000:32000 docker run -m 1250m --ulimit nofile=16000:16000 ``` 3. メモリの問題の場合,コンテナのメモリ上限を上げて試してみると ```docker run -m 3000m elasticsearch:5.3.2``` 4. ES_HEAP_SIZEという環境変数でJava VMのヒープサイズ上限を指定してみる https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html を見ると、メモリの半分以下が推奨されているので、とりあえず400Mにしておく。 ``` docker run -m 1250m -e "ES_HEAP_SIZE=400m" elasticsearch:5.3.2 ``` すると、こんなエラーが出るかもしれないので,(環境変数の名前が変わったよというエラーらしい) ``` Error: encountered environment variables that are no longer supported Use jvm.options or ES_JAVA_OPTS to configure the JVM ES_HEAP_SIZE=400m: set -Xms400m and -Xmx400m in jvm.options or add "-Xms400m -Xmx400m" to ES_JAVA_OPTS ``` エラーメッセージのままに、環境変数の指定を変える。 ``` docker run -m 1250m -e "ES_JAVA_OPTS=-Xms400m -Xmx400m" elasticsearch:5.3.2 ``` [Change Heap Size Document(ElasticSearch)](https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html) ## データが投入できない デフォルトではインデックスのマッピングフィールド数がデフォルトでは1000くらいなのでそれを拡張してあげる必要がある。 ``` curl -XPUT 'localhost:9200/<index_name>/_settings' -H 'Content-Type: application/json' -d ' { "index.mapping.total_fields.limit": 3000 }' {"acknowledged":true}⏎ ``` * https://www.elastic.co/guide/en/elasticsearch/reference/master/mapping.html#mapping-limit-settings * https://discuss.elastic.co/t/approaches-to-deal-with-limit-of-total-fields-1000-in-index-has-been-exceeded/241039
×
Sign in
Email
Password
Forgot password
or
Sign in via Google
Sign in via Facebook
Sign in via X(Twitter)
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
Continue with a different method
New to HackMD?
Sign up
By signing in, you agree to our
terms of service
.