{"id":15502966,"url":"https://github.com/evuez/rubber","last_synced_at":"2025-12-11T23:49:58.811Z","repository":{"id":57494044,"uuid":"116940029","full_name":"evuez/rubber","owner":"evuez","description":"🔍 A DSL-free Elasticsearch client written in Elixir.","archived":false,"fork":false,"pushed_at":"2018-03-05T07:57:31.000Z","size":136,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-17T17:40:25.895Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://hex.pm/packages/rubber","language":"Elixir","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/evuez.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-10T09:53:45.000Z","updated_at":"2023-01-01T16:38:44.000Z","dependencies_parsed_at":"2022-09-02T01:40:32.076Z","dependency_job_id":null,"html_url":"https://github.com/evuez/rubber","commit_stats":null,"previous_names":["evuez/elastix-reloaded"],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evuez%2Frubber","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evuez%2Frubber/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evuez%2Frubber/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evuez%2Frubber/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/evuez","download_url":"https://codeload.github.com/evuez/rubber/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250338347,"owners_count":21414163,"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-10-02T09:11:42.701Z","updated_at":"2025-12-11T23:49:58.770Z","avatar_url":"https://github.com/evuez.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rubber [![Build Status](https://travis-ci.org/evuez/rubber.svg?branch=master)](https://travis-ci.org/evuez/rubber) [![Hex.pm](https://img.shields.io/hexpm/v/rubber.svg)](https://hex.pm/packages/rubber)\n\nA DSL-free Elasticsearch client written in Elixir (backward-compatible with [elastix](https://github.com/werbitzky/elastix) v0.5.0).\n\n[elastix](https://github.com/werbitzky/elastix) doesn't seem to be maintained anymore so I'll try to keep this fork up-to-date.\n\nI started off with `elastic-reloaded` for the name but then it got annoying because I wanted some consistency between the package name, the app name and the top module name so now it's `Rubber` everywhere.\n\n## Documentation\n\n* [Documentation on hexdocs.pm](https://hexdocs.pm/rubber/)\n* [Latest Elasticsearch documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html)\n\nEven though the [documentation](https://hexdocs.pm/rubber/) is pretty scarce right now, I'm working on improving it. Also if you want to help with that you're definitely welcome 🤗\n\nThis README contains most of the information you should need to get started, if you can't find what you're looking for, either look at the tests or file an issue!\n\n## Installation\n\nAdd `rubber` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [{:rubber, \"\u003e= 0.0.0\"}]\nend\n```\n\nThen run `mix deps.get` to fetch the new dependency.\n\n## Examples\n\n### Creating an Elasticsearch index\n\n```elixir\nRubber.Index.create(\"http://localhost:9200\", \"twitter\", %{})\n```\n\n### Map, Index, Search and Delete\n\n```elixir\nelastic_url = \"http://localhost:9200\"\n\ndata = %{\n    user: \"kimchy\",\n    post_date: \"2009-11-15T14:12:12\",\n    message: \"trying out Rubber\"\n}\n\nmapping = %{\n  properties: %{\n    user: %{type: \"text\"},\n    post_date: %{type: \"date\"},\n    message: %{type: \"text\"}\n  }\n}\n\nRubber.Mapping.put(elastic_url, \"twitter\", \"tweet\", mapping)\nRubber.Document.index(elastic_url, \"twitter\", \"tweet\", \"42\", data)\nRubber.Search.search(elastic_url, \"twitter\", [\"tweet\"], %{})\nRubber.Document.delete(elastic_url, \"twitter\", \"tweet\", \"42\")\n```\n\n### Bulk requests\n\nBulk requests take as parameter a list of the lines you want to send to the [`_bulk`](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html) endpoint.\n\nYou can also specify the following options:\n\n* `index` the index of the request\n* `type` the document type of the request. *(you can't specify `type` without specifying `index`)*\n\n```elixir\nlines = [\n  %{index: %{_id: \"1\"}},\n  %{field: \"value1\"},\n  %{index: %{_id: \"2\"}},\n  %{field: \"value2\"}\n]\n\nRubber.Bulk.post(elastic_url, lines, index: \"my_index\", type: \"my_type\")\n\n# You can also send raw data:\ndata = Enum.map(lines, fn line -\u003e Poison.encode!(line) \u003c\u003e \"\\n\" end)\nRubber.Bulk.post_raw(elastic_url, data, index: \"my_index\", type: \"my_type\")\n```\n\n## Configuration\n\n### [Shield](https://www.elastic.co/products/shield)\n\n```elixir\nconfig :rubber,\n  shield: true,\n  username: \"username\",\n  password: \"password\",\n```\n\n### [Poison](https://github.com/devinus/poison) (or any other JSON library) and [HTTPoison](https://github.com/edgurgel/httpoison)\n\n```elixir\nconfig :rubber,\n  json_options: [keys: :atoms!],\n  httpoison_options: [hackney: [pool: :rubber_pool]]\n```\n\nNote that you can configure Rubber to use any JSON library, see the [\"Custom JSON codec\" page](https://hexdocs.pm/rubber/custom-json-codec.html) for more info.\n\n### Custom headers\n\n```elixir\nconfig :rubber,\n  custom_headers: {MyModule, :add_aws_signature, [\"us-east\"]}\n```\n\n`custom_headers` must be a tuple of the type `{Module, :function, [args]}`, where `:function` is a function that should accept the request (a map of this type: `%{method: String.t, headers: [], url: String.t, body: String.t}`) as its first parameter and return a list of the headers you want to send:\n\n```elixir\ndefmodule MyModule do\n  def add_aws_signature(request, region) do\n    [{\"Authorization\", generate_aws_signature(request, region)} | request.headers]\n  end\n\n  defp generate_aws_signature(request, region) do\n    # See: https://github.com/bryanjos/aws_auth or similar\n  end\nend\n```\n\n## Running tests\n\nYou need Elasticsearch running locally on port 9200. A quick way of doing so is via Docker:\n\n```\n$ docker run -p 9200:9200 -it --rm elasticsearch:5.1.2\n```\n\nThen clone the repo and fetch its dependencies:\n\n```\n$ git clone git@github.com:evuez/rubber.git\n$ cd rubber\n$ mix deps.get\n$ mix test\n```\n\n## License\n\n[elastix](https://github.com/werbitzky/elastix) was first licensed under the WTFPL by El Werbitzky \u003cwerbitzky@gmail.com\u003e.\nRubber is now distributed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevuez%2Frubber","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevuez%2Frubber","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevuez%2Frubber/lists"}