A working Ecto adapter for Elasticsearch that leverages Elasticsearch's SQL support to enable familiar Ecto query patterns for Elasticsearch indices.
- 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
- Comparison operators:
==,!=,>,<,>=,<= - Logical operators:
AND,OR - Membership operator:
IN - Null checks:
IS NULL,IS NOT NULL - Arithmetic operators:
+,-,*,/
COUNT()- Count recordsSUM()- Sum numeric valuesAVG()- Average of numeric valuesMAX()- Maximum valueMIN()- Minimum value
- INSERT - Insert single documents into indices
- Custom SELECT projections (single and multiple columns)
- storage_up - Create Elasticsearch indices
- storage_status - Check index status
- storage_down - Remove indices
- String (VARCHAR)
- Integer (INT)
- Parameter interpolation with
^operator - String escaping for SQL injection prevention
- Custom timeout configuration
- Aggregate queries with WHERE conditions
- Complex SELECT expressions with type casting
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 httpsuse adapter.
defmodule MyRepo do
use Ecto.Repo, otp_app: :my_app, adapter: EctoElk.Adapter
end$ INTEGRATION=1 mix testIf 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"}
]
endDocumentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/ecto_elk.