Completed
Branch v2 (10e463)
by Alexey
02:41
created

MultiQuery::createSearchResult()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 1
1
<?php namespace Bardex\Elastic;
2
3
class MultiQuery extends Query
4
{
5
    protected $queryList = [];
6
7
    public function addQuery(SearchQuery $query)
8
    {
9
        $this->queryList[] = $query;
10
        return $this;
11
    }
12
13
    public function getQuery()
14
    {
15
        $params = ['body' => []];
16
        foreach ($this->queryList as $query) {
17
            $query = $query->getQuery();
18
            $params['body'][] = [
19
                'index' => $query['index'],
20
                'type'  => $query['type'],
21
            ];
22
            $params['body'][] = $query['body'];
23
        }
24
        return $params;
25
    }
26
27
    public function fetchAll($hydration=true)
28
    {
29
        return $this->client->msearch($this->getQuery(), $hydration);
30
    }
31
32
}
33