LoginSignup
5
4

More than 5 years have passed since last update.

elasticsearch-rubyでprettyをtrueに指定する

Last updated at Posted at 2016-01-18

調べ方が悪かったのか、elasticsearch-rubyでpretty=trueを指定する方法が見つかリませんでした。

elastic/elasticsearch-ruby

elasticsearchをrubyから使うためのライブラリです。

APIの検索にヒットしない

elastic/elasticsearch-rubyから遷移できるAPIのドキュメントですが、
prettyをページ右上にあるSearchで検索してもヒットしません。

また、この検索フォームはページ内検索ではないようです。

APIのActions,Cat,...Utilsどれにもヒットしない

APIの(おそらく)全てのページ内でprettyで検索をかけましたが、やはりヒットしません。

指定方法

方法は簡単で、searchの引数のハッシュに指定するだけです。

client = Elasticsearch::Client.new log: true

client.search index: 'myindex',
              type: 'mytype' ,
              pretty: true,
              body: {
                  query: {
                      match: {
                          title: "qiita"
                      }
                  }
              }
5
4
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
5
4