Skip to content

Latest commit

 

History

History
34 lines (29 loc) · 888 Bytes

multi-type-search.md

File metadata and controls

34 lines (29 loc) · 888 Bytes

Multi type search

If you want to limit your search to just few selected types in given index you could do that this way:

fos_elastica:
    indexes:
        app:
            types:
                article:
                    properties:
                        title: ~
                        desc: ~
                    # ....
                news:
                    properties:
                        title: ~
                        desc: ~
                    # ....
$query = 'search-string';
$mngr = $this->get('fos_elastica.index_manager');

$search = $mngr->getIndex('app')->createSearch();
$search->addType('article');
$search->addType('news');
$resultSet = $search->search($query);

$transformer = $this->get('fos_elastica.elastica_to_model_transformer.collection.app');
$results = $transformer->transform($resultSet->getResults());