ExSift - High-performance MongoDB-style query filtering for Elixir

ExSift: High-performance MongoDB-style query filtering for Elixir

I’m working on ExSift, a high-performance library that uses sift.js-inspired MongoDB-style query syntax to filter Elixir collections.

What is it?

ExSift uses a MongoDB’s declarative syntax to filter lists of maps or structs. When creating dynamic search APIs, rule engines, or intricate data filtering logic (such as memory-only data or API answers) when Ecto queries aren’t suitable, it’s ideal.

Key Features

  • MongoDB Syntax: Supports standard operators like $eq, $gt, $in, $regex, $elemMatch, $and, $or, and many more.

  • Nested Support: Deeply query nested maps and lists using dot notation (e.g., %{ "user.address.city" => "New York" }).

  • High Performance: Recently optimized with a new compilation engine that pre-compiles queries into native Elixir function calls, resulting in a ~2.3x speedup over runtime interpretation.

  • Safe: Runs in pure Elixir, no external dependencies for the core logic.

Example

data = [
  %{name: "Alice", age: 30, role: "admin"},
  %{name: "Bob", age: 25, role: "user"},  
  %{name: "Charlie", age: 35, role: "user"}
]
        
query = %{
  "role" => "user",
  "age" => %{"$gt" => 20}
}
        
ExSift.filter(data, query)
# => [%{name: "Bob", ...}, %{name: "Charlie", ...}]

Links

I’d love to hear your feedback and see how you use it! I’m open to contributions :rocket:

Upvote1Downvote0Go to commentsShare

2 Likes

there is also this:

GitHub - botsquad/match_engine: In-memory matching/filtering engine with Mongo-like query syntax.

looks quite similar, though not exactly same.