Development

Parameters in Low Search

Low Search uses both native and its own parameters to generate search results.
All these parameters can be applied in two ways: as input fields
in a Form, or as hard-coded parameters in the Results or URL tag.
The values of these parameters can always be shown inside a Low Search tag
by using the parameter name as a variable, prefixed with low_search_.

So, any parameter:

param_name="param_value"

Is equal to:

<input name="param_name" value="param_value">

And the param_value can be shown with:

{low_search_param_name}

For example, take a look at these parameters, input fields and variables:

Note: Use input fields if you want the value of the parameter to be
user defined or logged to the Search Log. Use hard-coded parameters
if you want the value to be fixed.

Multiple values

In ExpressionEngine, multiple values of a parameter are usually separated by a vertical bar |.
This can also be translated into input fields, as long as the parameter name has square brackets
([]) appended to it. Then the same principle applies:

Inclusive values

The example above will filter results by any of the values given. However, ExpressionEngine
also allows you to filter by all of the values, by separating them with an ampersand
(&) rather than a vertical bar. Low Search also caters for this, using the
require_all parameter, which takes any amount of parameter names as its value. For example:

Exclude values

ExpressionEngine also allows you to exclude values, by prepending not to the parameter value,
which negates the value. Low Search also caters for this, using the exclude parameter,
which takes any amount of parameter names as its value. For example:

SQL parameters

As per version 3.4.0, Low Search supports SQL parameters. This means you can use a SQL query
in any pararameter. SQL queries are limited to SELECTs only and should
always end with a semi-colon (;). Low Search will take the first item in the
SELECT statement and creates a pipe-separated list from it. If the SQL query produces
no results, it sets the parameter value to what comes after the semi-colon. You can optionally prefix
the SQL query for better matching. Schematically, such a query looks like this:

param="prefix SELECT field FROM table WHERE lorem = 'ipsum';no results"

Regular Expression conditionals (EE 2.9.0 and up)

In EE 2.9.0 and higher, the same as the IN conditionals can be achieved with native conditionals using
the Matches Operator. The best way to approach this, would be like this:

{if pipe_separated_items ~ '/(^|\|)'.single_item.'($|\|)/'} ... {/if}

The pipe_separated_items and single_item variables should be written without curly braces. The latter is part of the regular expression using the string concatenation operator. Using regular expression conditionals, the above example would be written like this: