nseaSeb

nseaSeb

search_ash — multilingual Postgres full-text search for Ash

Hi everyone,

I’m building a multi-tenant SaaS (Ash + LiveView + Postgres) and needed a global search across several entity types — products, customers, orders… I wanted to avoid pulling in Elasticsearch/Meilisearch just for that, and couldn’t find an existing Ash-native solution, so I built one and open-sourced it.

search_ash v0.1 is a set of Ash extensions for full-text search on top of Postgres tsvector/ts_rank. No hand-written migrations or SQL. It’s built on two other libs I published alongside it: search_core (the non-Ash pipeline logic) and stemmers (a Rust NIF for Snowball stemming, 15+ languages including French).

It covers two use cases:

1. Per-resource search

defmodule MyApp.Post do
  use Ash.Resource,
    domain: MyApp.Blog,
    data_layer: AshPostgres.DataLayer,
    extensions: [SearchAsh]

  postgres do
    table "posts"
    repo MyApp.Repo
  end

  search do
    fields [:title, :body]
    language_attribute :language
  end
end

This generates, at compile time: a :search_text attribute, a change that keeps it in sync on create/update, a GIN expression index (round-trips cleanly with mix ash_postgres.generate_migrations), and a :search read action.

2. Global cross-entity search

This was my actual use case: searching across multiple resource types from one ranked query. SearchAsh.GlobalIndex + SearchAsh.Source maintain a unified index resource, with tenant-aware identities, soft-delete/archive support, and a :global_search action returning ranked, typed results.

Known 0.1 trade-offs (documented in the README, not surprises):

  • Indexing is synchronous (same transaction as the write) — no Oban/async path yet, maybe better to implement the asynch approach in the webapp
  • One language per query (no cross-language OR search)
  • Bulk updates on per-resource search do need strategy: :stream
  • Index creation isn’t CONCURRENTLY yet

There’s a runnable multi-tenant demo in examples/search_demo (Postgres-backed test suite, plus a GreenAsh console for browsing results).

Feedback, issues, and PRs very welcome.

Showing Posts 1 to 8

zachdaniel

zachdaniel

Creator of Ash

Cool :smiling_face_with_sunglasses:

nseaSeb

nseaSeb OP

Thank you, you make my day :wink:

Ash has been a joy to build on top of — this library wouldn’t exist without it. Let me know if anything in the DSL or extension design looks off from an Ash-core perspective, happy to iterate.

kip

kip

ex_cldr Core Team

Nice work.

If you want a pure Elixir snowball-based stemmer then text_stemmer provides the known 35 snowball stemmers and they all pass the conformance tests. It also integrates with localize too.

nseaSeb

nseaSeb OP

@kip Thank you, I’m making the change, sounds good to use it, I agree with U.
And I found an issue with the language, I’m fixing the issue in the same updgrade.

nseaSeb

nseaSeb OP

It’s done v 0.2 published.
Maybe I have to implement the user policies or add an approach to help for the policies, I take a look :thinking:

nseaSeb

nseaSeb OP

The policies are clear-cut: for me, the object type allows for filtering based on permissions, and since we expose the ID, the displayed result can account for those permissions if specific information needs to be hidden. Furthermore, any subsequent access to the object will naturally trigger the web app user’s read/write guards.
I am currently on version 0.3.1 and am evolving it to incorporate reindexing and pruning features tailored to my needs.
Does that sound right?

manhvu

manhvu

Nice job :ok_hand:

nseaSeb

nseaSeb OP

search_ash 0.4.0

Pushed a batch of stuff aimed at making a global search actually easy to wire into a real results page.

— All posts loaded —

Where Next? Top

Trending in Announcing Top

woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
MRdotB
I needed to reuse React components from my Chrome extension in my Phoenix/LiveView backend. I noticed that for Svelte/Vue, there are live...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
fuelen
Hi all! I want to present a small library which provides a mix task for generating an Entity-Relationship Diagram for Ecto schemas. You...
New
anuaralfetahe
Hello Published a new library - ProcessHub! ProcessHub is a library designed to manage process distribution within the Elixir cluster. ...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
AstonJ
This showed up on my feed.. anyone heard of it? Just hype? Ox Alpha is a reasoning model designed for coding, sustained ag...
New
sergio
It’s not that it’s vocabulary is too advanced. It’s something worse. I get lost trying to follow even a paragraph written by Claude. It’...
New
sorenone
Today we’re releasing Oban for Python. Not an Oban client in Python. Not a pythonx wrapper embedded in Elixir. Nope, it’s a fully operati...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
akoutmos
@hugobarauna, Dr. Dimitrios Koutmos (my brother) and I (Alex Koutmos) have been hard at work on writing a book on how you can use Elixir ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews