File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ Multi type search
2+ ===============
3+
4+ If you want to limit your search to just few selected types in given index you could do that this way:
5+
6+ ``` yaml
7+ fos_elastica :
8+ indexes :
9+ app :
10+ types :
11+ article :
12+ mappings :
13+ title : ~
14+ desc : ~
15+ # ....
16+ news :
17+ mappings :
18+ title : ~
19+ desc : ~
20+ # ....
21+ ```
22+
23+ ``` php
24+ $query = 'search-string';
25+ $mngr = $this->get('fos_elastica.index_manager');
26+
27+ $search = $mngr->getIndex('app')->createSearch();
28+ $search->addType('article');
29+ $search->addType('news');
30+ $resultSet = $search->search($query);
31+
32+ $transformer = $this->get('fos_elastica.elastica_to_model_transformer.collection.app');
33+ $results = $transformer->transform($resultSet->getResults());
34+ ```
Original file line number Diff line number Diff line change @@ -22,3 +22,4 @@ Cookbook Entries
2222* [ Clustering - Multiple Connections] ( cookbook/multiple-connections.md )
2323* [ Suppressing server errors] ( cookbook/suppress-server-errors.md )
2424* [ Hints on result hydration] ( cookbook/hints-on-result-hydration.md )
25+ * [ Multi type search] ( cookbook/multi-type-search.md )
You can’t perform that action at this time.
0 commit comments