View Source Glific.Searches (Glific v5.1.6)
The Searches context.
Link to this section Summary
Functions
Add permission specific to searches, in this case we want to restrict the visibility of contact ids where the contact is the main query table
Returns an %Ecto.Changeset{}
for tracking search changes.
Given a jsonb string, typically either from the database, or maybe via graphql convert the string keys to atoms
Returns the count of searches, using the same filter as list_saved_searches
Creates a search.
Deletes a search.
Gets a single search.
Returns the list of searches.
Execute a saved search, if term is sent in, it is added to the saved search. Either return conversations or count
Full text search interface via Postgres
Search across multiple tables, and return a multiple context result back to the frontend. First step in emulating a whatsapp search
Updates a search.
Link to this section Functions
@spec add_permission(Ecto.Query.t(), Glific.Users.User.t()) :: Ecto.Query.t()
Add permission specific to searches, in this case we want to restrict the visibility of contact ids where the contact is the main query table
@spec change_saved_search(Glific.Searches.SavedSearch.t(), map()) :: Ecto.Changeset.t()
Returns an %Ecto.Changeset{}
for tracking search changes.
examples
Examples
iex> change_saved_search(search)
%Ecto.Changeset{data: %Search{}}
Given a jsonb string, typically either from the database, or maybe via graphql convert the string keys to atoms
Returns the count of searches, using the same filter as list_saved_searches
@spec create_saved_search(map()) :: {:ok, Glific.Searches.SavedSearch.t()} | {:error, Ecto.Changeset.t()}
Creates a search.
examples
Examples
iex> create_saved_search(%{field: value})
{:ok, %SavedSearch{}}
iex> create_saved_search(%{field: bad_value})
{:error, %Ecto.Changeset{}}
@spec delete_saved_search(Glific.Searches.SavedSearch.t()) :: {:ok, Glific.Searches.SavedSearch.t()} | {:error, Ecto.Changeset.t()}
Deletes a search.
examples
Examples
iex> delete_saved_search(search)
{:ok, %SavedSearch{}}
iex> delete_saved_search(search)
{:error, %Ecto.Changeset{}}
@spec get_saved_search!(integer()) :: Glific.Searches.SavedSearch.t()
Gets a single search.
Raises Ecto.NoResultsError
if the SavedSearch does not exist.
examples
Examples
iex> get_saved_search!(123)
%SavedSearch{}
iex> get_saved_search!(456)
** (Ecto.NoResultsError)
@spec list_saved_searches(map()) :: [Glific.Searches.SavedSearch.t()]
Returns the list of searches.
examples
Examples
iex> list_saved_searches()
[%SavedSearch{}, ...]
@spec saved_search_count(map()) :: [Glific.Conversations.Conversation.t()] | integer()
Execute a saved search, if term is sent in, it is added to the saved search. Either return conversations or count
@spec search(map(), boolean()) :: [Glific.Conversations.Conversation.t()] | integer()
Full text search interface via Postgres
@spec search_multi(String.t(), map()) :: Glific.Searches.Search.t()
Search across multiple tables, and return a multiple context result back to the frontend. First step in emulating a whatsapp search
@spec update_saved_search(Glific.Searches.SavedSearch.t(), map()) :: {:ok, Glific.Searches.SavedSearch.t()} | {:error, Ecto.Changeset.t()}
Updates a search.
examples
Examples
iex> update_saved_search(search, %{field: new_value})
{:ok, %SavedSearch{}}
iex> update_saved_search(search, %{field: bad_value})
{:error, %Ecto.Changeset{}}