Uni Ecto Plugin !!exclusive!! -

Using PostgreSQL's Full-Text Search # lib/my_app/repo.ex defmodule MyApp.Repo do use Ecto.Repo, otp_app: :my_app Custom full-text search function def full_text_search(queryable, search_term, fields) do search_term = search_term |> String.trim() |> String.replace(~r/\s+/, " & ") # Convert spaces to & for AND operator

defp apply_full_text_search(query, %search_term: term) when is_binary(term) and term != "" do from q in query, where: fragment( "to_tsvector('english', ?) @@ plainto_tsquery('english', ?)", fragment("coalesce(?, '') || ' ' || coalesce(?, '')", q.title, q.content), ^term ) end defp apply_full_text_search(query, _), do: query uni ecto plugin

render(conn, "index.html", query: query, results: results, total_count: length(results) ) end Using PostgreSQL's Full-Text Search # lib/my_app/repo

json(conn, %suggestions: suggestions) end end # lib/my_app_web/live/search_live.ex defmodule MyAppWeb.SearchLive do use MyAppWeb, :live_view alias MyApp.Blog fields) do search_term = search_term |&gt