GithubHelp home page GithubHelp logo

isabella232 / elasticsearch-ruby Goto Github PK

View Code? Open in Web Editor NEW

This project forked from elastic/elasticsearch-ruby

0.0 0.0 0.0 7.25 MB

Ruby integrations for Elasticsearch

Home Page: https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/index.html

License: Apache License 2.0

Ruby 98.88% HTML 0.35% Dockerfile 0.03% Shell 0.74%

elasticsearch-ruby's Introduction

Elasticsearch

This repository contains Ruby integrations for Elasticsearch.

master Code Climate

The elasticsearch library is a wrapper for two separate libraries:

require 'elasticsearch'

client = Elasticsearch::Client.new log: true

# if you specify Elasticsearch host
# client = Elasticsearch::Client.new url: 'http://localhost:9200', log: true

client.transport.reload_connections!

client.cluster.health

client.search q: 'test'

# etc.

Both of these libraries are extensively documented. Please read the elasticsearch-transport and the elasticsearch-api documentation carefully.

See also doc/examples for some practical examples.

For optimal performance, you should use a HTTP library which supports persistent ("keep-alive") connections, e.g. Patron or Typhoeus. These libraries are not dependencies of the Elasticsearch gems. Ensure you define a dependency for a HTTP library in your own application.

This repository contains these additional Ruby libraries:

Please see their respective READMEs for information and documentation.

For integration with Ruby models and Rails applications, see the elasticsearch-rails project.

Compatibility

The Elasticsearch client is compatible with currently maintained Ruby versions. See Ruby Maintenance Branches. We don't provide support to versions which have reached their end of life.

The gem's version numbers follow Elasticsearch's major versions. The master branch is compatible with the Elasticsearch master branch, which is the next major version.

Gem Version Elasticsearch
0.90 0.90
1.x 1.x
2.x 2.x
5.x 5.x
6.x 6.x
7.x 7.x
master master

Use a release that matches the major version of Elasticsearch in your stack. Each client version is backwards compatible with all minor versions of the same major version. The client's API is compatible with Elasticsearch's API versions from 0.90 till current.

Check out Elastic product end of life dates to learn which releases are still actively supported and tested.

Installation

Install the elasticsearch package from Rubygems:

gem install elasticsearch

To use an unreleased version, either add it to your Gemfile for Bundler:

gem 'elasticsearch', git: 'git://github.com/elasticsearch/elasticsearch-ruby.git'

or install it from a source code checkout:

git clone https://github.com/elasticsearch/elasticsearch-ruby.git
cd elasticsearch-ruby/elasticsearch
bundle install
rake install

Development

To work on the code, clone and bootstrap the project first:

git clone https://github.com/elasticsearch/elasticsearch-ruby.git
cd elasticsearch-ruby/
bundle exec rake setup
bundle exec rake bundle

This will clone the Elasticsearch repository into the project, and run bundle install in all subprojects. There are a few tasks to work with Elasticsearch. Use rake -T and look for the tasks in the elasticsearch namespace. You can build elasticsearch with rake elasticsearch:build after having ran setup.

To run tests, you need to start a testing cluster on port 9250, or provide a different one in the TEST_CLUSTER_PORT environment variable.

There's a Rake task to start the testing cluster. By default this is going to try and use the elasticsearch command on your system:

rake test:cluster:start

You can also configure where the elasticsearch startup script is found with the TEST_CLUSTER_COMMAND environment variable, e.g.:

TEST_CLUSTER_COMMAND=~/elasticsearch/bin/elasticsearch rake test:cluster:stop

You also can configure the port, number of nodes, and other settings with environment variables:

TEST_CLUSTER_COMMAND=./tmp/builds/elasticsearch-7.10.0-SNAPSHOT/bin/elasticsearch \
TEST_CLUSTER_PORT=9250 \
TEST_CLUSTER_NODES=2 \
TEST_CLUSTER_NAME=my_cluster \
ES_JAVA_OPTS='-Xms500m -Xmx500m' \
TEST_CLUSTER_TIMEOUT=120 \
rake test:cluster:start

You can stop the cluster with a rake task, passing in the TEST_CLUSTER_COMMAND variable:

TEST_CLUSTER_COMMAND=./tmp/builds/elasticsearch-7.10.0-SNAPSHOT/bin/elasticsearch \
rake test:cluster:stop

There's also a rake task for starting up Elasticsearch in a Docker container: rake docker:start[version] - E.g.: rake docker:start[7.x-SNAPSHOT]. To start the container with X-Pack, pass it in as a parameter: rake docker:start[7.x-SNAPSHOT,xpack].

To run tests against unreleased Elasticsearch versions, you can use the rake elasticsearch:build Rake task to build Elasticsearch from the cloned source (use rake elasticsearch:update to update the repository):

Note: If you have gems from the elasticsearch family installed system-wide, and want to use development ones, prepend the command with bundle exec.

rake elasticsearch:build

This is going to create the build in ./tmp/builds/.

You can pass a branch name (tag, commit, ...) as the Rake task variable:

rake elasticsearch:build[origin/1.x]

To run all the tests in all the subprojects, use the Rake task:

time rake test:client

By default, tests will atempt to use http://localhost:9200 as a test server. If you're using a different host/port, set the TEST_ES_SERVER environment variable, e.g.:

$ TEST_ES_SERVER='http://localhost:9250' be rake test:client

License

This software is licensed under the Apache 2 license.

elasticsearch-ruby's People

Contributors

aaronrustad avatar akfernun avatar amatsuda avatar andrewvc avatar betamatt avatar chrisbr avatar conky5 avatar cosmo0920 avatar ctrochalakis avatar defgenx avatar edgurgel avatar estolfo avatar fabn avatar gmile avatar h6ah4i avatar jsvd avatar jyaworski avatar karmi avatar karmiq avatar kkirsche avatar konklone avatar mindreframer avatar mkdynamic avatar philkra avatar picandocodigo avatar pragtob avatar robsteranium avatar stephenprater avatar szabosteve avatar trevorcreech avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.