Skip to main content
Version: 2024.2

Search Modifiers

Search modifiers can influence the search results by modifying the search query. They can be used to filter, sort or aggregate the search results.

Search modifiers can be added to the search via the addModifier() method of the search object.

$search->addModifier(new ParentIdFilter(1))

Available Search Modifiers

Filters

ModifierModifier CategoryDescription
IdFilterBasic filtersFilter by element ID
IdsFilterBasic filtersFilter by multiple element IDs
ExcludeFoldersFilterBasic filtersExclude folders from search result
ParentIdsFilterTree related filtersFilter by parent ID
PathFilterTree related filtersFilter by path (depending on use case for all levels or direct children only and with or without the parent item included)
TagFilterTree related filtersFilter by tag IDs (it is also possible to include child tags)
AssetMetaDataFilterAsset filtersFilter by asset meta data attribute. The format of the $data which needs to be passed depends on the type of the meta data attribute and is handled by its field definition adapter.
WorkspaceQueryWorkspace related filtersFilter based on the user workspaces and permissions for a defined element type (this query is added to the asset/document/data object search by default)
ElementWorkspacesQueryWorkspace related filtersFilter based on the user workspaces and permissions respecting all element types (this query is added to the element search by default)

Full Text Search Queries

ModifierModifier CategoryDescription
ElementKeySearchFull text searchSearch by element key like in the studio UI.

* can be used for wildcard searches - for example "Car*" to find all items starting with "Car".

Dependencies

ModifierModifier CategoryDescription
RequiresFilterDependenciesGet all elements which the given element requires.
RequiredByFilterDependenciesGet all elements which are required by the given element.

Query Language

ModifierModifier CategoryDescription
PqlFilterQuery LanguageApply a Pimcore Query Language (PQL) condition.

Sort Modifiers

ModifierModifier CategoryDescription
OrderByFullPathTree related sortingOrder by full path (including element key)
OrderByPageNumberSearch related sortingUse inverted search for large amounts of data (this modifier is added to the search when there are at least 1000 results by default, and page number is above the half of total pages. Furthermore, existing sorting has to be already applied.)

Aggregations

ModifierModifier CategoryDescription
ChildrenCountAggregationTree related aggregationGet children counts for given element IDs.
AssetMetaDataAggregationAssetsUsed for the filters in the asset grid to aggregate the filter options for supported meta data types.

Add your own search modifier

To add a custom search modifier implementation two steps are necessary:

  1. Create a new class that implements the Pimcore\Bundle\GenericDataIndexBundle\Model\Search\Modifier\ModifierInterface interface. This model class should contain all configurable attributes for the modifier. Take a look at the IdFilter for an example.

  2. Create a service to implement the logic behind the modifier and add the AsSearchModifierHandler attribute. The attribute can either be directly added to the method which implements to logic or to a class. If added to a class the ´__invoke` method will be used as the handler.

The implemented method needs exactly two arguments.:

Take a look at the BasicFilters for an example and the OpenSearch search models documentation for more details about the search models to manipulate the search.