언어/Ruby

ruby elasticsearch client

파아랑새 2020. 5. 26. 20:34
require 'elasticsearch/transport'
require 'elasticsearch'

client = Elasticsearch::Client.new hosts: [
    { host: '',
      port: 9200,
      user: "",
      password: ""
    }
]

#client.index  index: 'myindex', type: 'mytype', id: 1, body: { title: 'Test' }
response = client.search index: 'myindex', body: { query: { match: { title: 'test' } } }
puts response["hits"]["hits"][0]["_source"]
require import