{"id":13508819,"url":"https://github.com/werbitzky/elastix","last_synced_at":"2025-05-14T15:07:25.164Z","repository":{"id":34850499,"uuid":"38844640","full_name":"werbitzky/elastix","owner":"werbitzky","description":"A simple Elasticsearch REST client written in Elixir.","archived":false,"fork":false,"pushed_at":"2025-02-28T09:39:09.000Z","size":228,"stargazers_count":253,"open_issues_count":9,"forks_count":73,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-05-12T11:53:15.979Z","etag":null,"topics":["elastic","elasticsearch","elixir-lang","index","json","rest","search"],"latest_commit_sha":null,"homepage":"","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/werbitzky.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-07-09T20:50:07.000Z","updated_at":"2025-02-28T09:39:13.000Z","dependencies_parsed_at":"2025-01-09T15:44:05.473Z","dependency_job_id":"80c279f9-3146-4190-b4fc-7c8ad3741cb8","html_url":"https://github.com/werbitzky/elastix","commit_stats":{"total_commits":146,"total_committers":30,"mean_commits":4.866666666666666,"dds":0.547945205479452,"last_synced_commit":"9afc57c9de3c3014d25b62d11e806433e72c35ba"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/werbitzky%2Felastix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/werbitzky%2Felastix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/werbitzky%2Felastix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/werbitzky%2Felastix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/werbitzky","download_url":"https://codeload.github.com/werbitzky/elastix/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254169658,"owners_count":22026213,"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":["elastic","elasticsearch","elixir-lang","index","json","rest","search"],"created_at":"2024-08-01T02:00:58.920Z","updated_at":"2025-05-14T15:07:25.135Z","avatar_url":"https://github.com/werbitzky.png","language":"Elixir","funding_links":[],"categories":["ORM and Datamapping"],"sub_categories":[],"readme":"# Elastix\n\n[![Build Status](https://travis-ci.org/werbitzky/elastix.svg)](https://travis-ci.org/werbitzky/elastix)\n[![Hex Version](https://img.shields.io/hexpm/v/elastix.svg)](https://hex.pm/packages/elastix)\n[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/elastix/)\n[![Hex Downloads](https://img.shields.io/hexpm/dt/elastix.svg)](https://hex.pm/packages/elastix)\n[![WTFPL](https://img.shields.io/badge/license-WTFPL-brightgreen.svg?style=flat)](https://www.tldrlegal.com/l/wtfpl)\n[![Last Updated](https://img.shields.io/github/last-commit/werbitzky/elastix.svg)](https://github.com/werbitzky/elastix/commits/master)\n\nA DSL-free Elasticsearch client for Elixir.\n\n## Documentation\n\n* [Documentation on hexdocs.pm](https://hexdocs.pm/elastix/)\n* [Latest Elasticsearch documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html)\n\nEven though the [documentation](https://hexdocs.pm/elastix/) is pretty scarce right now, we're working on improving it. 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 `:elastix` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:elastix, \"\u003e= 0.0.0\"}\n  ]\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\nElastix.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 Elastix\"\n}\n\nmapping = %{\n  properties: %{\n    user: %{type: \"text\"},\n    post_date: %{type: \"date\"},\n    message: %{type: \"text\"}\n  }\n}\n\nElastix.Mapping.put(elastic_url, \"twitter\", \"tweet\", mapping)\nElastix.Document.index(elastic_url, \"twitter\", \"tweet\", \"42\", data)\nElastix.Search.search(elastic_url, \"twitter\", [\"tweet\"], %{})\nElastix.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* `httpoison_options` configuration directly passed to httpoison methods. Same options that can be passed on config file\n\n```elixir\nlines = [\n  %{index: %{_id: \"1\"}},\n  %{field: \"value1\"},\n  %{index: %{_id: \"2\"}},\n  %{field: \"value2\"}\n]\n\nElastix.Bulk.post(elastic_url, lines, index: \"my_index\", type: \"my_type\", httpoison_options: [timeout: 180_000])\n\n# You can also send raw data:\ndata = Enum.map(lines, fn line -\u003e Poison.encode!(line) \u003c\u003e \"\\n\" end)\nElastix.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 :elastix,\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 :elastix,\n  json_options: [keys: :atoms!],\n  httpoison_options: [hackney: [pool: :elastix_pool]]\n```\n\nNote that you can configure Elastix to use any JSON library, see the [\"Custom JSON codec\" page](https://hexdocs.pm/elastix/custom-json-codec.html) for more info.\n\n### Custom headers\n\n```elixir\nconfig :elastix,\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:werbitzky/elastix.git\n$ cd elastix\n$ mix deps.get\n$ mix test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwerbitzky%2Felastix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwerbitzky%2Felastix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwerbitzky%2Felastix/lists"}