Introduction
suggest changeElasticsearch has a well-documented JSON API, but you’ll probably want a library that handles it for you:
Elasticsearch- the official low level wrapper for the HTTP APIElasticsearch-rails- the official high-level Rails integration that connects Rails models with Elasticsearch using Active Record or the repository patternChewy- An alternative, non-official high level Rails integration that is very popular and arguably has better documentation
Let’s use the first option for testing the connection:
gem install elasticsearch
Then start irb and try it:
require 'elasticsearch'
client = Elasticsearch::Client.new log: true
# by default it connects to http://localhost:9200
client.transport.reload_connections!
client.cluster.health
client.search q: 'test'
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents