engineeringdept

engineeringdept

Snap - an Elasticsearch client for Elixir

I’ve just released the first version of Snap, an Elasticsearch client. It borrows ideas about application structure and process management from Ecto, as well as a DSL-free nature and zero-downtime index management from Elasticsearch.

It adds support for using Streams to perform bulk operations against an index, as well as emitting Telemetry events.

It’s new and probably not production ready yet. I expect to introduce it into a production environment in the coming weeks, and expect some changes will follow.

Please feel free to kick the tyres on it, and see if it’s useful for you. Feedback welcome!

Most Liked

engineeringdept

engineeringdept

Hi there - the library is in production use and has been actively developed since my posting. I believe other people are also using it now.

engineeringdept

engineeringdept

0.6.0 is out which supports the ability to swap HTTP clients, allowing mock HTTP clients for testing, or to use your preferred HTTP client for whatever reason. It still defaults to using Finch.

Full changelog here: snap/CHANGELOG.md at master · breakroom/snap · GitHub

engineeringdept

engineeringdept

I’ve just released Snap 0.9.0, which adds support for the Document API in Snap.Document, exposes a Snap.Search.count function for counting documents in an index, and some quality of life and testing improvements with an index namespacing feature.

The index namespacing feature allows a Snap.Cluster to be isolated on a per-application or per-environment basis so you can have your dev environment indexes be prefixed with dev- and your test environment be prefixed with test- etc.

It also allows us to isolate indexes on a per-process basis, which enables asynchronous tests to be isolated from each other, so they operate on their own view of the cluster’s indexes. This is similar to how Ecto sandboxing works, but within the constraints of ElasticSearch/OpenSearch which doesn’t support transactions.

This makes it possible to set async: true in your tests which is often a nice performance improvement.

I’m really open to feedback on this API - let me know if it does what you expect, in the way you expect it!

For more details see Snap.Cluster.Namespace and Snap.Test.

engineeringdept

engineeringdept

I’ve just released 0.5.0 which includes a bunch of improvements since my last post from other users of the library - see the CHANGELOG. Thanks to everyone who has contributed!

bdarla

bdarla

I managed to find out how to draft such queries. In case someone might also needs to make such queries, I provide an example below, that can be provided to Snap:

query = %{
      query: %{
        span_near: %{
          clauses: [
            %{
              span_multi: %{
                match: %{
                  wildcard: %{
                    "doc.values.description": %{
                      value: "comput*"
                    }
                  }
                }
              }
            },
            %{
              span_multi: %{
                match: %{
                  wildcard: %{
                    "doc.values.description": %{
                      value: "inform*"
                    }
                  }
                }
              }
            }
          ],
          slop: 14,
          in_order: false
        }
      }
    }

Where Next?

Popular in Libraries Top

scohen
Lexical Lexical is a next-generation language server for the Elixir programming language. Features Context aware code completion As-you...
New
benlime
I created a new library GitHub - benvp/ex_cva: Class Variance Authority for Elixir which aims to make it very easy to define different va...
New
cjen07
parameterized pipe in elixir: |n> edit: negative index in |n> and mixed usage with |> are supported example: use ParamP...
New
vic
Expat is a tiny experiment I did for extracting patterns and being able to reuse them (compose and share patterns between elixir librarie...
New
markmark206
simple_feature_flags is a tiny package that lets you turn features on or off based on which environment (e.g. localhost, staging, product...
New
nikokozak
Hello all, I’ve been working on Svonix - a library for quickly integrating Svelte components into Phoenix views. It’s a much-needed succ...
New
michalmuskala
Hello everybody. I have just released Jason - a new JSON library. You might be wondering, why do we need a new library? The primary foc...
New
aditya7iyengar
Rummage.Ecto and Rummage.Phoenix provide ways to perform Searching, Sorting and Pagination over Ecto queries and Phoenix collections. Fo...
New
woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
Antrater
Hi everyone! I’m thrilled to announce a huge thing. We have been developing Elixir Moon Design System for quite a while. We are finally ...
New

Other popular topics Top

fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 42633 214
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
magnetic
Hey :wave:t3: Elixir community, I’ve been learning Elixir, and working on some side projects. My editor of choice is VSCode, and althoug...
New

Sub Categories:

We're in Beta

About us Mission Statement