{"id":13880193,"url":"https://github.com/github/elastomer-client","last_synced_at":"2025-05-15T08:00:23.136Z","repository":{"id":5021635,"uuid":"6180360","full_name":"github/elastomer-client","owner":"github","description":"A library for interacting with Elasticsearch","archived":false,"fork":false,"pushed_at":"2025-03-18T22:40:00.000Z","size":2078,"stargazers_count":196,"open_issues_count":11,"forks_count":25,"subscribers_count":314,"default_branch":"main","last_synced_at":"2025-04-14T13:04:47.075Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/github.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2012-10-11T20:33:17.000Z","updated_at":"2025-03-13T18:25:59.000Z","dependencies_parsed_at":"2023-12-20T11:09:43.980Z","dependency_job_id":"ce4c5188-f2fa-41ff-8754-bd59a2cdd3d4","html_url":"https://github.com/github/elastomer-client","commit_stats":{"total_commits":1098,"total_committers":28,"mean_commits":"39.214285714285715","dds":0.6092896174863388,"last_synced_commit":"78707f1d633e3f5068b12490e61151008922b7cf"},"previous_names":[],"tags_count":59,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/github%2Felastomer-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/github%2Felastomer-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/github%2Felastomer-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/github%2Felastomer-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/github","download_url":"https://codeload.github.com/github/elastomer-client/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254301420,"owners_count":22047901,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-06T08:02:51.263Z","updated_at":"2025-05-15T08:00:23.027Z","avatar_url":"https://github.com/github.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# ElastomerClient [![CI build Workflow](https://github.com/github/elastomer-client/actions/workflows/main.yml/badge.svg)](https://github.com/github/elastomer-client/actions/workflows/main.yml)\n\nMaking a stupid simple Elasticsearch client so your project can be smarter!\n\n## Client\n\nThe client provides a one-to-one mapping to the Elasticsearch [API\nendpoints](https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html).\nThe API is decomposed into logical sections and accessed according to what you\nare trying to accomplish. Each logical section is represented as a [client\nclass](lib/elastomer_client/client) and a top-level accessor is provided for each.\n\n#### Cluster\n\nAPI endpoints dealing with cluster level information and settings are found in\nthe [Cluster](lib/elastomer_client/client/cluster.rb) class.\n\n```ruby\nrequire 'elastomer_client/client'\nclient = ElastomerClient::Client.new\n\n# the current health summary\nclient.cluster.health\n\n# detailed cluster state information\nclient.cluster.state\n\n# the list of all index templates\nclient.cluster.templates\n```\n\n#### Index\n\nThe methods in the [Index](lib/elastomer_client/client/index.rb) class deal with the\nmanagement of indexes in the cluster. This includes setting up type mappings\nand adjusting settings. The actual indexing and search of documents are\nhandled by the Docs class (discussed next).\n\n```ruby\nrequire 'elastomer_client/client'\nclient = ElastomerClient::Client.new\n\nindex = client.index('books')\nindex.create(\n  :settings =\u003e { 'index.number_of_shards' =\u003e 3 },\n  :mappings =\u003e {\n    :_source =\u003e { :enabled =\u003e true },\n    :properties =\u003e {\n      :author =\u003e { :type =\u003e 'keyword' },\n      :title  =\u003e { :type =\u003e 'text' }\n    }\n  }\n)\n\nindex.exists?\n\nindex.delete\n```\n\n#### Docs\n\nThe [Docs](lib/elastomer_client/client/docs.rb) class handles the indexing and\nsearching of documents. Each instance is scoped to an index and optionally a\ndocument type.\n\n```ruby\nrequire 'elastomer_client/client'\nclient = ElastomerClient::Client.new\n\ndocs = client.docs('books')\n\ndocs.index({\n  :_id    =\u003e 1,\n  :author =\u003e 'Mark Twain',\n  :title  =\u003e 'The Adventures of Huckleberry Finn'\n})\n\ndocs.search({:query =\u003e {:match_all =\u003e {}}})\n```\n\n#### Performance\n\nBy default ElastomerClient uses Net::HTTP (via Faraday) to communicate with\nElasticsearch. You may find that Excon performs better for your use. To enable\nExcon, add it to your bundle and then change your ElastomerClient initialization\nthusly:\n\n```ruby\nElastomerClient::Client.new(url: YOUR_ES_URL, adapter: :excon)\n```\n\n#### Retries\n\nYou 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:\n\n```ruby\nretry_options = {\n  max: 2,\n  interval: 0.05,\n  methods: [:get]\n}\n\nElastomerClient::Client.new do |connection|\n  connection.request :retry, retry_options\nend\n```\n\n## Compatibility\n\nThis client is tested against:\n\n- Ruby version 3.2\n- Elasticsearch versions 5.6 and 8.13\n\n## Development\n\nGet started by cloning and running a few scripts:\n\n- [ElastomerClient ](#elastomerclient-)\n  - [Client](#client)\n      - [Cluster](#cluster)\n      - [Index](#index)\n      - [Docs](#docs)\n      - [Performance](#performance)\n  - [Compatibility](#compatibility)\n  - [Development](#development)\n    - [Bootstrap the project](#bootstrap-the-project)\n    - [Start an Elasticsearch server in Docker](#start-an-elasticsearch-server-in-docker)\n    - [Run tests against a version of Elasticsearch](#run-tests-against-a-version-of-elasticsearch)\n  - [Releasing](#releasing)\n\n### Bootstrap the project\n\n```\nscript/bootstrap\n```\n\n### Start an Elasticsearch server in Docker\n\nTo run ES 5 and ES 8:\n```\ndocker compose --project-directory docker --profile all up\n```\n\nTo run in ES8 cross cluster replication mode:\n```\nscript/setup-ccr up \"{non-production license}\"\n```\n\nTo run only ES 8:\n```\ndocker compose --project-directory docker --profile es8 up\n```\n\nTo run only ES 5:\n```\ndocker compose --project-directory docker --profile es5 up\n```\n\n### Run tests against a version of Elasticsearch\n\nES 8\n```\nES_PORT=9208 rake test\n```\n\nCCR tests:\n```\nES_PORT=9208 ES_REPLICA_PORT=9209 rake test\n```\n\nES 5\n```\nES_PORT=9205 rake test\n```\n\n## Releasing\n\n1. Create a new branch from `main`\n1. Bump the version number in `lib/elastomer/version.rb`\n1. Update `CHANGELOG.md` with info about the new version\n1. Commit your changes and tag the commit with a version number starting with the prefix \"v\" e.g. `v4.0.2`\n1. Execute `rake build`. This will place a new gem file in the `pkg/` folder.\n1. Run `gem install pkg/elastomer-client-{VERSION}.gem` to install the new gem locally\n1. Start an `irb` session, `require \"elastomer/client\"` and make sure things work as you expect\n1. Once everything is working as you expect, push both your commit and your tag, and open a pull request\n1. Request review from a maintainer and wait for the pull request to be approved. Once it is approved, you can merge it to `main` yourself. After that, pull down a fresh copy of `main` and then...\n1. [Optional] If you intend to release a new version to Rubygems, run `rake release`\n1. [Optional] If necessary, manually push the new version to rubygems.org\n1. 🕺 💃 🎉\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgithub%2Felastomer-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgithub%2Felastomer-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgithub%2Felastomer-client/lists"}