Z.Contacts (Portico/Z v0.1.0)
Context for Contacts (humans)
Link to this section Summary
Functions
Search contacts by a series of comparisons.
Link to this section Functions
Link to this function
search(comparisons, opts \\ [])
Search contacts by a series of comparisons.
comparisons
can be either a Map
or a Keyword
list. Field names to match can be String
or Atom
values. Handy!
Opts
You can pass the following opts
:similarity
- float between0.0
(everything) and1.0
(exact match). The default is0.7
, which is a nice balance of "pretty much what you asked for".:limit
- The number of results to return - the default is100
.return_query
(boolean). If this is sent astrue
, then theEcto.Query
will be returned instead of the query result. This can be handy for chaining with other searches.
Note that this returns a list of ZSchemas.Flat.Contact{}
structs, mostly for convenience because when searching you don't typically want a big pile of related structs crushing your search load.
Examples
iex> Z.Contacts.search(first_name: "Donald")
[%ZSchemas.Flat.Contact{}, ...]
iex> Z.Contacts.search(%{first_name: "Donald"}, limit: 1, similarity: 0.4)
[%ZSchemas.Flat.Contact{}]