Zatvobor/tirexs
{ "createdAt": "2013-02-14T16:22:03Z", "defaultBranch": "master", "description": "An Elixir flavored HTTP client and DSL library for Elasticsearch", "fullName": "Zatvobor/tirexs", "homepage": "https://hexdocs.pm/tirexs/api-reference.html", "language": "Elixir", "name": "tirexs", "pushedAt": "2022-01-10T05:34:18Z", "stargazersCount": 427, "topics": [ "elasticsearch" ], "updatedAt": "2025-10-12T16:52:17Z", "url": "https://github.com/Zatvobor/tirexs"}An Elixir flavored HTTP client and DSL library for building JSON based settings, mappings, queries to Elasticsearch engine.
Getting Started
Section titled “Getting Started”- Add this to the
defp deps dolist in your mix.exs file:
{:tirexs, "~> 0.8"}-
Also in mix.exs, add
:tirexsto the:applicationslist indef application. -
In config/dev.exs, configure
tirexs:# The default uri is http://127.0.0.1:9200config :tirexs, :uri, "http://127.0.0.1:9200"See lib/tirexs/env.ex for more configuration options.
-
Index a document:
import Tirexs.HTTP
put("/my_index/users/1", [name: "Jane", email: "jane@example.com"])# {:ok, 201,# %{_id: "1", _index: "my_index", _type: "users", _version: 1, created: true}}- Fetch the document:
get("/my_index/users/1")# {:ok, 200,# %{_id: "1", _index: "my_index",# _source: %{email: "jane@example.com", name: "Jane"}, _type: "users",# _version: 1, found: true}}- Simplified search:
get("/my_index/users/_search?q=name:jane")# {:ok, 200,# %{_shards: %{failed: 0, successful: 5, total: 5},# hits: %{hits: [%{_id: "1", _index: "my_index", _score: 0.30685282,# _source: %{email: "jane@example.com", name: "Jane"}, _type: "users"}],# max_score: 0.30685282, total: 1}, timed_out: false, took: 10}}- Query DSL
import Tirexs.Search
query = search [index: "my_index"] do query do match "name", "jane" endend# [search: [query: [match: [name: [query: "jane"]]]], index: "my_index"]
Tirexs.Query.create_resource(query)# {:ok, 200,# %{_shards: %{failed: 0, successful: 5, total: 5},# hits: %{hits: [%{_id: "1", _index: "my_index", _score: 0.30685282,# _source: %{email: "jane@example.com", name: "Jane"}, _type: "users"}],# max_score: 0.30685282, total: 1}, timed_out: false, took: 5}}Check out [/examples]!(/examples) directory as a quick intro.
tirexs is split into several layers
Section titled “tirexs is split into several layers”- Raw HTTP layer and API helpers
- Multiple operations in single call such as Bulk API and mget API
- DSL flavored helpers
Find out more in api reference
Not sure?
Section titled “Not sure?”Look around using https://hex.pm/packages?search=elasticsearch… to find out some other packages.
Contributing
Section titled “Contributing”If you feel like porting or fixing something, please drop a pull request or issue tracker at GitHub! Check out the [CONTRIBUTING.md]!(CONTRIBUTING.md) for more details.
License
Section titled “License”Tirexs source code is released under Apache 2 License.
Check [LICENSE]!(LICENSE) and [NOTICE]!(NOTICE) files for more details. The project HEAD is https://github.com/zatvobor/tirexs.