
Security News
Follow-up and Clarification on Recent Malicious Ruby Gems Campaign
A clarification on our recent research investigating 60 malicious Ruby gems.
The elasticsearch
library provides a Ruby client and API for Elasticsearch.
This gem is a wrapper for two separate libraries:
elastic-transport
, which provides a low-level Ruby client for connecting to Elastic services.elasticsearch-api
, which provides a Ruby API for the Elasticsearch RESTful API.Install the elasticsearch
package and use the API directly:
require 'elasticsearch'
client = Elasticsearch::Client.new(log: true)
client.cluster.health
client.transport.reload_connections!
client.search(q: 'test')
# etc.
Features overview:
(For integration with Ruby models and Rails applications, see the https://github.com/elasticsearch/elasticsearch-rails project.)
We follow Ruby’s own maintenance policy and officially support all currently maintained versions per Ruby Maintenance Branches.
Language clients are forward compatible; meaning that clients support communicating with greater minor versions of Elasticsearch. Elastic language clients are also backwards compatible with lesser supported minor Elasticsearch versions.
Install the 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
The X-Opaque-Id header allows to track certain calls, or associate certain tasks with the client that started them (more on the Elasticsearch docs). To use this feature, you need to set an id for opaque_id
on the client on each request. Example:
client = Elasticsearch::Client.new
client.search(index: 'myindex', q: 'title:test', opaque_id: '123456')
The search request will include the following HTTP Header:
X-Opaque-Id: 123456
You can also set a prefix for X-Opaque-Id when initializing the client. This will be prepended to the id you set before each request if you're using X-Opaque-Id. Example:
client = Elastic::Transport::Client.new(opaque_id_prefix: 'eu-west1_')
client.search(index: 'myindex', q: 'title:test', opaque_id: '123456')
The request will include the following HTTP Header:
X-Opaque-Id: eu-west1_123456
You can use API Key authentication:
Elasticsearch::Client.new(
host: host,
transport_options: transport_options,
api_key: credentials
)
Where credentials is either the base64 encoding of id
and api_key
joined by a colon or a hash with the id
and api_key
:
Elasticsearch::Client.new(
host: host,
transport_options: transport_options,
api_key: {id: 'my_id', api_key: 'my_api_key'}
)
Please refer to the specific library documentation for details:
Transport: [README] [Documentation]
API: [README] [Documentation]
This software is licensed under the Apache 2 license.
FAQs
Unknown package
We found that elasticsearch demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.
Security News
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.
Research
/Security News
A malicious Go module posing as an SSH brute forcer exfiltrates stolen credentials to a Telegram bot controlled by a Russian-speaking threat actor.