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 doneedstrategy: :stream - Index creation isn’t
CONCURRENTLYyet
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.
Trending in Announcing
Other Trending Topics
Latest Ash Threads
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #phoenix_html
- #iex
- #ai
- #graphql
- #genstage
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex











Showing Posts 1 to 8- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
zachdaniel
Cool
nseaSeb
Thank you, you make my day
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
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
@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
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
nseaSeb
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
Nice job
nseaSeb
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.