Bombadil - A tiny wrapper around some PostgreSQL search capabilities

Bombadil is a tiny wrapper around some PostgreSQL search capabilities

It supports exact match through PostgreSQL tsvector(s) and fuzzy search inside
jsonb fields.

An excerpt from the README in the repository about the usage:

alias Bombadil.Ecto.Schema.SearchIndex

iex> Bombadil.index(SearchIndex, payload: %{"book" => "Lord of the Rings"})
:ok
iex> Bombadil.search("Lord of the Rings")
[
  %Bombadil.Ecto.Schema.SearchIndex{
    __meta__: #Ecto.Schema.Metadata<:loaded, "search_index">,
    payload: %{"book" => "Lord of the Rings"},
    id: 1
  }
]
iex> Bombadil.fuzzy_search(SearchIndex, "lord of the ringz")
[
  %Bombadil.Ecto.Schema.SearchIndex{
    __meta__: #Ecto.Schema.Metadata<:loaded, "search_index">,
    payload: %{"book" => "Lord of the Rings"},
    id: 1
  }
]

Thank you!

5 Likes

Nice library :+1:
One question: why does Bombadil define its own Repo and supervision tree? I was expecting it to simply generate the Ecto query that I could feed into my own applications Repo.

4 Likes

@mbuhot
My plan is to achieve that point.
I will put it in the todo list of the project. Thank you !

2 Likes

Published


A “Repo-less” release

So you can use your ecto repo in this way:

iex> YourEctoRepo.all(Bombadil.fuzzy_search(SearchIndex, "lord of the ringz"))

Checkout https://github.com/kpanic/bombadil/pull/8 if you are curious

Thank you for your feedback!

5 Likes