ecto_searcher v0.2.0 EctoSearcher.Searcher View Source
Module for searching
Usage
search = %{"name_eq" => "Donald Trump", "description_cont" => "My president"}
query = EctoSearcher.Searcher.search(MyMegaModel, search)
MySuperApp.Repo.all(query)
Link to this section Summary
Link to this section Functions
Link to this function
search(base_query, schema, search_params) View Source
Shortcut for search/5
with Default
as mapping
and nil
as searchable_fields
Link to this function
search(base_query, schema, search_params, searchable_fields) View Source
Shortcut for search/5
with Default
as mapping
Link to this function
search(base_query, schema, search_params, mapping, searchable_fields \\ nil) View Source
Builds search query
Takes %Ecto.Query{}
as base_query
and ecto model as schema
.
search_params
should be a map with search_fields in form of "field_matcher"
like this:
%{
"name_eq" => "Donald Trump",
"description_cont" => "My president"
}
mapping
should implement EctoSearcher.Mapping
behavior. EctoSearcher.Mapping.Default
provides some basics.
searchable_fields
is a list with fields (atoms) permitted for searching. If not provided (or nil
) all fields are allowed for searching.