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 between 0.0 (everything) and 1.0 (exact match). The default is 0.7, which is a nice balance of "pretty much what you asked for".
  • :limit - The number of results to return - the default is 100.
  • return_query (boolean). If this is sent as true, then the Ecto.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{}]