Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Making a stupid simple Elasticsearch client so your project can be smarter!
The client provides a one-to-one mapping to the Elasticsearch API endpoints. The API is decomposed into logical sections and accessed according to what you are trying to accomplish. Each logical section is represented as a client class and a top-level accessor is provided for each.
API endpoints dealing with cluster level information and settings are found in the Cluster class.
require 'elastomer_client/client'
client = ElastomerClient::Client.new
# the current health summary
client.cluster.health
# detailed cluster state information
client.cluster.state
# the list of all index templates
client.cluster.templates
The methods in the Index class deal with the management of indexes in the cluster. This includes setting up type mappings and adjusting settings. The actual indexing and search of documents are handled by the Docs class (discussed next).
require 'elastomer_client/client'
client = ElastomerClient::Client.new
index = client.index('books')
index.create(
:settings => { 'index.number_of_shards' => 3 },
:mappings => {
:_source => { :enabled => true },
:properties => {
:author => { :type => 'keyword' },
:title => { :type => 'text' }
}
}
)
index.exists?
index.delete
The Docs class handles the indexing and searching of documents. Each instance is scoped to an index and optionally a document type.
require 'elastomer_client/client'
client = ElastomerClient::Client.new
docs = client.docs('books')
docs.index({
:_id => 1,
:author => 'Mark Twain',
:title => 'The Adventures of Huckleberry Finn'
})
docs.search({:query => {:match_all => {}}})
By default ElastomerClient uses Net::HTTP (via Faraday) to communicate with Elasticsearch. You may find that Excon performs better for your use. To enable Excon, add it to your bundle and then change your ElastomerClient initialization thusly:
ElastomerClient::Client.new(url: YOUR_ES_URL, adapter: :excon)
You can add retry logic to your Elastomer client connection using Faraday's Retry middleware. The ElastomerClient::Client.new
method can accept a block, which you can use to customize the Faraday connection. Here's an example:
retry_options = {
max: 2,
interval: 0.05,
methods: [:get]
}
ElastomerClient::Client.new do |connection|
connection.request :retry, retry_options
end
This client is tested against:
Get started by cloning and running a few scripts:
script/bootstrap
To run ES 5 and ES 8:
docker compose --project-directory docker --profile all up
To run only ES 8:
docker compose --project-directory docker --profile es8 up
To run only ES 5:
docker compose --project-directory docker --profile es5 up
ES 8
ES_PORT=9208 rake test
ES 5
ES_PORT=9205 rake test
main
lib/elastomer/version.rb
CHANGELOG.md
with info about the new versionv4.0.2
rake build
. This will place a new gem file in the pkg/
folder.gem install pkg/elastomer-client-{VERSION}.gem
to install the new gem locallyirb
session, require "elastomer/client"
and make sure things work as you expectmain
yourself. After that, pull down a fresh copy of main
and then...rake release
FAQs
Unknown package
We found that elastomer-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.