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    #[\Override]
20    public function readSearchResultList($querystring)
21    {
22        $boolquery = Helper::boolFilteredQuery();
23        $searchquery = new \Elastica\Query\QueryString();
24        if ('' === trim($querystring)) {
25            $searchquery->setQuery('*');
26        } else {
27            $searchquery->setQuery($querystring);
28        }
29        $searchquery->setFields([
30            'name^9',
31            'keywords^5'
32        ]);
33        $boolquery->getQuery()->addShould($searchquery);
34        $filter = null;
35        $query = new \Elastica\Query\Filtered($boolquery, $filter);
36        $resultList = $this->access()
37            ->getIndex()
38            ->getType('topic')
39            ->search($query, 1000);
40        $topicList = new Collection();
41        foreach ($resultList as $result) {
42            $topic = new Entity($result->getData());
43            $topicList[$topic['id']] = $topic;
44        }
45        return $topicList;
46    }
47}