Skip to content

Commit 0fb3e7c

Browse files
committed
Merge pull request #1006 from vlcekmi3/multi-type-search-doc
docs: multi-type search
2 parents 9804bae + bbc6a4b commit 0fb3e7c

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
```

Resources/doc/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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)

0 commit comments

Comments
 (0)