- Issue created by @a.dmitriiev
- Status changed to Needs review
11 months ago 4:08pm 27 December 2023 - 🇩🇪Germany a.dmitriiev
I have added new search_ui_element plugin "Exposed filter" (exposed_filter). This is only for UI settings so that the client knows that there are filters that user can use, it is not influencing in any way the result on the endpoint itself. 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
-
a.dmitriiev →
committed 808b7381 on 1.x
Issue #3411032: Add exposed filter UI Element
-
a.dmitriiev →
committed 808b7381 on 1.x
- Status changed to Fixed
11 months ago 9:17am 29 December 2023 - 🇩🇪Germany a.dmitriiev
Reviewed by client team, the new version of client 1.1.1 was released to support exposed filters.
- 🇩🇪Germany a.dmitriiev
Documentation page was added https://www.drupal.org/docs/extending-drupal/contributed-modules/contrib... →
Automatically closed - issue fixed for 2 weeks with no activity.