Created by: jason-uh
This PR adds a pluggable search feature to Administrate. Instead of a simple boolean, searchable
can now also take a class that implements #query/2
, #search_term
, and #with_context/1
. There is a DefaultSearch
implementation that other searches can extend.
Usage
Searches can be labeled with their attribute or, without an attribute, they will be grouped in the "special" :all
label that will be run against any searchable attribute. Labeled searches will always be preferred to the :all
label. In addition, labels can be specified more than once to enable searching for multiple values within the attribute. Finally, "op: and" can be used to turn the default "OR" operator to an "AND" operator when creating the outer query conditions (multiple occurrences of a labeled search will always use an "OR" search unless overridden by the search definition).
Examples:
On the Line Items page of the example application this search will find all line items which are either for The Game of Life product, have a unit price greater than or equal to $63.00, or whose order comes to a total price greater than or equal to $190.00.
`product: Game of Life, unit_price: 63, total_price: 190`
This search is similar to the above but uses "AND" for the outer query, and thus requires all of the search terms to be true.
`op: and, product: Game of Life, unit_price: 63, total_price: 190`