Exposed filter
Plugin search_ui_element plugin "Exposed filter" (exposed_filter) informs client about the filters that user can use, it is not influencing in any way the result on the endpoint itself if no payload is sent in the request. It is still possible to filter by any field that is in the index.
Client needs to send the field_name from search ui element setting as query parameter to the search endpoint. In case of multivalue filter when IN operator should be used the query should look like ?<field_name>[]=1&<field_name>[]=2. In case of "between" operator the query should look like ?<field_name>[min]=1&<field_name>[max]=2 (min/max are not hardcoded, it can be also from/to or any other key, but for "Between" operator it is mandatory to have exactly 2 values and first value will be minimum value and second - maximum).
To be able also construct the query for complex filters easily the new operator query parameter was added. It is possible to set the operator explicitly (for "equal", "between" and "in" the operator is implied, not need to set it in the query, see explanation above). Operator query parameter should be an array with keys that represent the filter field names, that should also be passed as query parameter.
The allowed operators are:
[
'equal' => t('Equal'),
'between' => t('Between'),
'gt' => t('Greater than'),
'gte' => t('Greater than or equal'),
'lt' => t('Less than'),
'lte' => t('Less than or equal'),
'not_equal' => t('Not equal'),
'not_in' => t('Not in'),
]Example query for all items that have created date greater than or equal to certain timestamp (e.g. 1638467243): ?created=1638467243&operator[created]=gte
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion