ElasticQuery   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
c 0
b 0
f 0
dl 0
loc 17
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A addTerm() 0 10 1
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
            'fuzzy'  => $fuzzy
36
        ];
37
38
        return $this;
39
    }
40
}
41