Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Finding your High with Low Search

Finding your High with Low Search

An introduction to Low Search for ExpressionEngine, given at EEconf 2016.

Lodewijk Schutte

October 04, 2016
Tweet

More Decks by Lodewijk Schutte

Other Decks in Programming

Transcript

  1. Searching vs. Filtering •In ExpressionEngine, searching == filtering. •Filter output

    by setting parameters to the Channel Entries Tag. •Low Search extends the CE Tag, offering more parameters and thus more control.
  2. {exp:low_search:results} Read parameters, run filters Set fixed_order or entry_id parameter

    Call {exp:channel:entries} Post-process returned entries Return search results
  3. {exp:low_search:results collection="products" keywords="luke cage" category:type="7|8" category:gender="11" search:size="=XL|XXL" range-to:price="30" orderby_sort="price|asc" }

    All mens tees and hoodies in size XL or XXL, up to $30, that match the terms "luke cage", ordered by price, ascending.
  4. A parameter… •…can be fixed:
 {exp:low_search:results name="value"} •…can be dynamic,

    using a form:
 <input name="name" value="value"> •…can be read as a variable:
 {low_search_name} => value
  5. {exp:low_search:form result_page="search/results"} <input name="keywords" value=""> <select name="category:type[]" multiple>…</select <input name="search:size[]"

    type="checkbox" value="XL"> XL … <input name="range-to:price" type="range" min="10" max="250" step="10"> <select name="limit">…</select> other form fields {/exp:low_search:form}
  6. A filter… •…consists of any amount of parameters. •…runs one

    or more (simple) queries. •…passes its results onto the next. •…triggers no_results when it comes up empty.
  7. Keywords •Matches entries against given keywords •Uses a full-text index

    created via collections •Allows for speed and relevance •Allows for inflections and stemming •Order by relevance score
  8. Field Search •Like native search:field_name parameter •Can target title, url_title

    and status •Can target Grid (or Matrix) columns •Additional matching, like starts_with •Smart Field Search option
  9. Ranges •Targets numeric or date fields •Two values, one field;

    optionally specify min/max values separately •Can also target Grid (or Matrix) columns •Inverse ranges (two fields, one value)
  10. Categories •Accepts category_ids •Combine AND and OR by specifying groups

    on the fly: •category:color="1|2|3" •category:type="4|5|6" •category:style="7|8|9"
  11. Relationships •Accepts entry_ids or url_titles •Can target the parent or

    child entry: •parent:field_name="1|2|3" •child:field_name="4|5|6"
  12. Distance •Uses Haversine algorithm •From given lat/lon values to one

    or two fields containing the entry’s coordinates •Specify max radius and unit •Order by calculated distance
  13. class Low_search_filter_foo extends Low_search_filter { public function filter($entry_ids) { return

    $entry_ids; } public function fixed_order() { return FALSE; } public function results($rows) { return $rows; } }