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