Lines
0.00%
0 / 21
Functions and Methods
0.00%
0 / 1
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Link | 0.00% | 0 / 21 | 0.00% | 0 / 1 | 20 | 0.00% | 0 / 1 | |||
| readSearchResultList | 0.00% | 0 / 21 | 0.00% | 0 / 1 | 20 | |||||
| 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\Link as Entity; | |
| 11 | use BO\Zmsdldb\Collection\Links as Collection; | |
| 12 | use BO\Zmsdldb\File\Link as Base; | |
| 13 | ||
| 14 | class Link extends Base | |
| 15 | { | |
| 16 | /** | |
| 17 | * @return Collection | |
| 18 | */ | |
| 19 | #[\Override] | |
| 20 | public function readSearchResultList(mixed $query) | |
| 21 | { | |
| 22 | $boolquery = Helper::boolFilteredQuery(); | |
| 23 | $searchquery = new \Elastica\Query\QueryString(); | |
| 24 | if ('' === trim($query)) { | |
| 25 | $searchquery->setQuery('*'); | |
| 26 | } else { | |
| 27 | $searchquery->setQuery($query); | |
| 28 | } | |
| 29 | $searchquery->setFields([ | |
| 30 | 'name^3', | |
| 31 | 'meta.titles^5', | |
| 32 | 'meta.keywords^9' | |
| 33 | ]); | |
| 34 | $boolquery->getQuery()->addShould($searchquery); | |
| 35 | $resultList = $this->access() | |
| 36 | ->getIndex() | |
| 37 | ->getType('links') | |
| 38 | ->search($boolquery, 1000); | |
| 39 | $linkList = new Collection(); | |
| 40 | foreach ($resultList as $result) { | |
| 41 | $link = new Entity($result->getData()); | |
| 42 | if (false === $linkList->offsetExists($link['link'])) { | |
| 43 | $linkList[$link['link']] = $link; | |
| 44 | } | |
| 45 | } | |
| 46 | return $linkList; | |
| 47 | } | |
| 48 | } |