EctoTsvector.Query (ecto_tsvector v0.1.0)
Summary
Functions
Applies a tsvector search to a query, using the primary schema of the query.
Functions
@spec tsvector_search_query(Ecto.Query.t(), String.t(), Keyword.t()) :: Ecto.Query.t()
Applies a tsvector search to a query, using the primary schema of the query.
Options
* `:vector_field` - Set the field name to use for the search vector, defaults to `:search_vector`.
* `:language_field` - Set the field name to use for the search language, defaults to `:search_language`.
Examples
def search_workspace_messages(workspace, search_term) do
Message
|> where([m], m.workspace_id == ^workspace.id)
|> EctoTsvector.Query.tsvector_search_query(search_term)
|> limit(10)
|> Repo.all()
end