Passed
Push — main ( f6374d...4050c0 )
by Simon
01:31
created

ElasticQuery::addOrFilters()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 3
rs 10
1
<?php
2
/**
3
 * class ElasticQuery|Firesphere\ElasticSearch\Queries\ElasticQuery Base of an Elastic Query
4
 *
5
 * @package Firesphere\Elastic\Search
6
 * @author Simon `Firesphere` Erkelens; Marco `Sheepy` Hermo
7
 * @copyright Copyright (c) 2018 - now() Firesphere & Sheepy
8
 */
9
10
namespace Firesphere\ElasticSearch\Queries;
11
12
use Firesphere\SearchBackend\Queries\BaseQuery;
13
use SilverStripe\Core\Injector\Injectable;
14
15
/**
16
 * Class BaseQuery is the base of every query executed.
17
 *
18
 * Build a query to execute agains Elastic. Uses as simle as possible an interface.
19
 *
20
 * @package Firesphere\Elastic\Search
21
 */
22
class ElasticQuery extends BaseQuery
23
{
24
    use Injectable;
25
26
    /**
27
     * @inheritDoc
28
     */
29
    public function addTerm(string $term, array $fields = [], int $boost = 1, $fuzzy = null): self
30
    {
31
        $this->terms[] = [
32
            'text'   => $term,
33
            'fields' => $fields,
34
            'boost'  => $boost
35
        ];
36
37
        return $this;
38
    }
39
}
40