Skip to content

A working Ecto adapter for Elasticsearch that leverages Elasticsearch's SQL support to enable familiar Ecto query patterns for Elasticsearch indices.

License

Notifications You must be signed in to change notification settings

bit4bit/ecto_elk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EctoElk

A working Ecto adapter for Elasticsearch that leverages Elasticsearch's SQL support to enable familiar Ecto query patterns for Elasticsearch indices.

Supported Features

Query Operations

  • SELECT queries - Retrieve records from Elasticsearch indices
  • WHERE clauses - Filter records with conditions
  • LIMIT - Limit the number of results returned
  • ORDER BY - Sort results (ASC/DESC, single and multiple columns)
  • GROUP BY - Group results by columns

Query Operators

  • Comparison operators: ==, !=, >, <, >=, <=
  • Logical operators: AND, OR
  • Membership operator: IN
  • Null checks: IS NULL, IS NOT NULL
  • Arithmetic operators: +, -, *, /

Aggregate Functions

  • COUNT() - Count records
  • SUM() - Sum numeric values
  • AVG() - Average of numeric values
  • MAX() - Maximum value
  • MIN() - Minimum value

Schema Operations

  • INSERT - Insert single documents into indices
  • Custom SELECT projections (single and multiple columns)

Storage Operations

  • storage_up - Create Elasticsearch indices
  • storage_status - Check index status
  • storage_down - Remove indices

Type Support

  • String (VARCHAR)
  • Integer (INT)

Query Features

  • Parameter interpolation with ^ operator
  • String escaping for SQL injection prevention
  • Custom timeout configuration
  • Aggregate queries with WHERE conditions
  • Complex SELECT expressions with type casting

Limitations

The following Ecto features are not yet implemented:

  • UPDATE operations
  • DELETE operations
  • INSERT_ALL (bulk inserts)
  • JOINS
  • Subqueries
  • Transactions
  • Locking
  • Migrations
  • Autogenerate for primary keys
  • Streams

config.exs

config :ecto_elk, MyRepo,
  hostname: "localhost"
  port: 9200,
  secure: false #true to enable https

use adapter.

defmodule MyRepo do
  use Ecto.Repo, otp_app: :my_app, adapter: EctoElk.Adapter
end

Contributing

$ INTEGRATION=1 mix test

Guides

Installation

If available in Hex, the package can be installed by adding ecto_elk to your list of dependencies in mix.exs:

def deps do
  [
    {:ecto_elk, "~> 0.1.0"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/ecto_elk.

About

A working Ecto adapter for Elasticsearch that leverages Elasticsearch's SQL support to enable familiar Ecto query patterns for Elasticsearch indices.

Topics

Resources

License

Stars

Watchers

Forks

Languages