LoginSignup
2
1

More than 5 years have passed since last update.

Elasticsearch のバージョンアップではまった事

Last updated at Posted at 2018-01-30

Elasticsearch のバージョンアップが激しすぎて少し目を話していたら大幅において行かれていました
現在、本番環境で動いているのは1.5なのですが、これを5.6系 にアップデートしようと思います
なお、記事執筆時点で6.1系がリリースされていますが、1.5系から一気に6.1系にアップデートするよりも、5.6系にアップしてから6.1系にアップデートする方が良いだろうという判断で5.6系を選択しております

リクエストパラメータが変更されている

リクエストヘッダの明示的な指定

  • リクエストヘッダに「Content-Type: application/json」を明示的に指定してください。
[誤]  curl                                     -XGET "http://gessy0129.com:9200/results/auction/_search" --data '{"query":{"match_all":{}}}'
[正]  curl -H "Content-Type: application/json" -XGET "http://gessy0129.com:9200/results/auction/_search" --data '{"query":{"match_all":{}}}'
  • 「Content-Type: application/json」を指定しないと elasticsearchのログに下記「warnning」が記載されます。
    • 次のバージョン(6.0)からは指定が必須となり、未指定の場合はエラーになります。
----------------------------------------------------------------------------------------------------------------
Content type detection for rest requests is deprecated. Specify the content type using the [Content-Type] header
----------------------------------------------------------------------------------------------------------------

使用しなくなったオプション

  • zero_terms_query
  • operator

便利になったこと

  • 検索結果が不要でヒット件数だけ取得したい場合は _search ではなく _count にリクエストを投げれば件数取得ができる
curl -H "Content-Type: application/json" -XGET "http://gessy0129.com:9200/results/auction/_count" --data '{"query":{"match_all":{}}}'

補足

今回記載した内容はあくまでもバージョンアップしたプロダクトではまった事なので、
これが全てではないです

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