Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 21 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| Topic | |
0.00% |
0 / 21 |
|
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 1 |
| readSearchResultList | |
0.00% |
0 / 21 |
|
0.00% |
0 / 1 |
12 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * @package ClientDldb |
| 5 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG |
| 6 | **/ |
| 7 | |
| 8 | namespace BO\Zmsdldb\Elastic; |
| 9 | |
| 10 | use BO\Zmsdldb\Entity\Topic as Entity; |
| 11 | use BO\Zmsdldb\Collection\Topics as Collection; |
| 12 | use BO\Zmsdldb\File\Topic as Base; |
| 13 | |
| 14 | /** |
| 15 | * |
| 16 | */ |
| 17 | class Topic extends Base |
| 18 | { |
| 19 | public function readSearchResultList($query) |
| 20 | { |
| 21 | $boolquery = Helper::boolFilteredQuery(); |
| 22 | $searchquery = new \Elastica\Query\QueryString(); |
| 23 | if ('' === trim($query)) { |
| 24 | $searchquery->setQuery('*'); |
| 25 | } else { |
| 26 | $searchquery->setQuery($query); |
| 27 | } |
| 28 | $searchquery->setFields([ |
| 29 | 'name^9', |
| 30 | 'keywords^5' |
| 31 | ]); |
| 32 | $boolquery->getQuery()->addShould($searchquery); |
| 33 | $filter = null; |
| 34 | $query = new \Elastica\Query\Filtered($boolquery, $filter); |
| 35 | $resultList = $this->access() |
| 36 | ->getIndex() |
| 37 | ->getType('topic') |
| 38 | ->search($query, 1000); |
| 39 | $topicList = new Collection(); |
| 40 | foreach ($resultList as $result) { |
| 41 | $topic = new Entity($result->getData()); |
| 42 | $topicList[$topic['id']] = $topic; |
| 43 | } |
| 44 | return $topicList; |
| 45 | } |
| 46 | } |