Menu

Maslosoft Manganel Logo Maslosoft Manganel Documentation
Elasticsearch for Mangan

Edit

Tag Filter Decorator

This is advanced topic, for basic usage it is not required. Misused will yield unexpected results.

Tag Query Decorator

This decorator will allow tag-like syntax for query string to filter results along with normal query, or no query at all to just return all documents with specific tag.

To search like that use square brackets. For example to search famous tagged cities starting with word New, following query could be used:

New [famous]

This query could return for example famous New York, but not New Hampshire which is not famous at all.

Configuring

Tag decorator is optional, so it needs to be added to configuration of Manganel.

Configuration for TagDecorator should be placed at beginning of $decorators property.

At minimum it is required to provide field which contains tags. This field should store comma or space separated values.

Example part of configuration containing TagDecorator:

'decorators' = [
    SearchCriteria::class => [
        ...
        [
            'class' => TagDecorator::class,
            'field' => 'tag'
        ],
        ...
];

Example of configuring with EmbeDi (recommended)

$config = [
    'manganel' => [
        'class' => Manganel::class,
        'decorators' => [
            SearchCriteria::class => [
                [
                    'class' => TagDecorator::class,
                    'field' => 'tag'
                ]
            ]
        ]
    ]
];

EmbeDi::fly()->addAdapter(new ArrayAdapter($config));

Then configured with EmbeDi, the newly created Manganel instances will have TagDecorator added with field tag.