All Projects → werbitzky → Elastix

werbitzky / Elastix

A simple Elasticsearch REST client written in Elixir.

Programming Languages

elixir
2628 projects

Projects that are alternatives of or similar to Elastix

Elasticsql
convert sql to elasticsearch DSL in golang(go)
Stars: ✭ 687 (+197.4%)
Mutual labels:  elastic, search, elasticsearch
Elasticsearch Ruby
Ruby integrations for Elasticsearch
Stars: ✭ 1,848 (+700%)
Mutual labels:  elastic, search, elasticsearch
Query Translator
Query Translator is a search query translator with AST representation
Stars: ✭ 165 (-28.57%)
Mutual labels:  search, elasticsearch
Rusticsearch
Lightweight Elasticsearch compatible search server.
Stars: ✭ 171 (-25.97%)
Mutual labels:  search, elasticsearch
Docker Elastic Stack
ELK Stack Dockerfile
Stars: ✭ 175 (-24.24%)
Mutual labels:  elastic, elasticsearch
Goat
[DEPRECATED] 🐐 A minimalistic JSON API server in Go
Stars: ✭ 161 (-30.3%)
Mutual labels:  rest, json
Api Diff
A command line tool for diffing json rest APIs
Stars: ✭ 164 (-29%)
Mutual labels:  rest, json
Jkes
A search framework and multi-tenant search platform based on java, kafka, kafka connect, elasticsearch
Stars: ✭ 173 (-25.11%)
Mutual labels:  search, elasticsearch
Vuex Search
Vuex binding for client-side search with indexers and Web Workers 📗🔍
Stars: ✭ 147 (-36.36%)
Mutual labels:  search, index
Jsonapi Utils
Build JSON API-compliant APIs on Rails with no (or less) learning curve.
Stars: ✭ 191 (-17.32%)
Mutual labels:  rest, json
Flexirest
Flexirest - The really flexible REST API client for Ruby
Stars: ✭ 188 (-18.61%)
Mutual labels:  rest, json
Book Elastic Search In Action
Elastic 搜索开发实战
Stars: ✭ 205 (-11.26%)
Mutual labels:  search, elasticsearch
Restinstance
Robot Framework library for RESTful JSON APIs
Stars: ✭ 157 (-32.03%)
Mutual labels:  rest, json
Flask Restplus
Fully featured framework for fast, easy and documented API development with Flask
Stars: ✭ 2,585 (+1019.05%)
Mutual labels:  rest, json
Keycloak Config Cli
Import YAML/JSON-formatted configuration files into Keycloak - Configuration as Code for Keycloak.
Stars: ✭ 147 (-36.36%)
Mutual labels:  rest, json
Tlog
Terminal I/O logger
Stars: ✭ 170 (-26.41%)
Mutual labels:  json, elasticsearch
Elasticsearch Comrade
Elasticsearch admin panel built for ops and monitoring
Stars: ✭ 214 (-7.36%)
Mutual labels:  elastic, elasticsearch
Json Logging Python
Python logging library to emit JSON log that can be easily indexed and searchable by logging infrastructure such as ELK, EFK, AWS Cloudwatch, GCP Stackdriver
Stars: ✭ 143 (-38.1%)
Mutual labels:  json, elasticsearch
Grafanajsondatasource
Grafana datasource to load JSON data over your arbitrary HTTP backend
Stars: ✭ 146 (-36.8%)
Mutual labels:  rest, json
Search Server
⭐️ Our core search API repository
Stars: ✭ 181 (-21.65%)
Mutual labels:  search, elasticsearch

Elastix Hex Version Hex Downloads Build Status WTFPL

A DSL-free Elasticsearch client for Elixir.

Documentation

Even though the documentation is pretty scarce right now, we're working on improving it. If you want to help with that you're definitely welcome 🤗

This 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!

Installation

Add elastix to your list of dependencies in mix.exs:

def deps do
  [{:elastix, ">= 0.0.0"}]
end

Then run mix deps.get to fetch the new dependency.

Examples

Creating an Elasticsearch index

Elastix.Index.create("http://localhost:9200", "twitter", %{})

Map, Index, Search and Delete

elastic_url = "http://localhost:9200"

data = %{
    user: "kimchy",
    post_date: "2009-11-15T14:12:12",
    message: "trying out Elastix"
}

mapping = %{
  properties: %{
    user: %{type: "text"},
    post_date: %{type: "date"},
    message: %{type: "text"}
  }
}

Elastix.Mapping.put(elastic_url, "twitter", "tweet", mapping)
Elastix.Document.index(elastic_url, "twitter", "tweet", "42", data)
Elastix.Search.search(elastic_url, "twitter", ["tweet"], %{})
Elastix.Document.delete(elastic_url, "twitter", "tweet", "42")

Bulk requests

Bulk requests take as parameter a list of the lines you want to send to the _bulk endpoint.

You can also specify the following options:

  • index the index of the request
  • type the document type of the request. (you can't specify type without specifying index)
  • httpoison_options configuration directly passed to httpoison methods. Same options that can be passed on config file
lines = [
  %{index: %{_id: "1"}},
  %{field: "value1"},
  %{index: %{_id: "2"}},
  %{field: "value2"}
]

Elastix.Bulk.post(elastic_url, lines, index: "my_index", type: "my_type", httpoison_options: [timeout: 180_000])

# You can also send raw data:
data = Enum.map(lines, fn line -> Poison.encode!(line) <> "\n" end)
Elastix.Bulk.post_raw(elastic_url, data, index: "my_index", type: "my_type")

Configuration

Shield

config :elastix,
  shield: true,
  username: "username",
  password: "password",

Poison (or any other JSON library) and HTTPoison

config :elastix,
  json_options: [keys: :atoms!],
  httpoison_options: [hackney: [pool: :elastix_pool]]

Note that you can configure Elastix to use any JSON library, see the "Custom JSON codec" page for more info.

Custom headers

config :elastix,
  custom_headers: {MyModule, :add_aws_signature, ["us-east"]}

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:

defmodule MyModule do
  def add_aws_signature(request, region) do
    [{"Authorization", generate_aws_signature(request, region)} | request.headers]
  end

  defp generate_aws_signature(request, region) do
    # See: https://github.com/bryanjos/aws_auth or similar
  end
end

Running tests

You need Elasticsearch running locally on port 9200. A quick way of doing so is via Docker:

$ docker run -p 9200:9200 -it --rm elasticsearch:5.1.2

Then clone the repo and fetch its dependencies:

$ git clone [email protected]:werbitzky/elastix.git
$ cd elastix
$ mix deps.get
$ mix test

License

Copyright © 2017 El Werbitzky [email protected]

This work is free. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].