1
|
|
|
<?php namespace Nord\Lumen\Elasticsearch\Search\Query\TermLevel; |
2
|
|
|
|
3
|
|
|
use Nord\Lumen\Elasticsearch\Search\Query\QueryDSL; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* While the full text queries will analyze the query string before executing, the term-level queries operate on the |
7
|
|
|
* exact terms that are stored in the inverted index. |
8
|
|
|
* |
9
|
|
|
* These queries are usually used for structured data like numbers, dates, and enums, rather than full text fields. |
10
|
|
|
* Alternatively, they allow you to craft low-level queries, foregoing the analysis process. |
11
|
|
|
* |
12
|
|
|
* The queries in this group are: |
13
|
|
|
* |
14
|
|
|
* - "term" query |
15
|
|
|
* Find documents which contain the exact term specified in the field specified. |
16
|
|
|
* |
17
|
|
|
* - "terms" query |
18
|
|
|
* Find documents which contain any of the exact terms specified in the field specified. |
19
|
|
|
* |
20
|
|
|
* - "range" query |
21
|
|
|
* Find documents where the field specified contains values (dates, numbers, or strings) in the range specified. |
22
|
|
|
* |
23
|
|
|
* - "exists" query |
24
|
|
|
* Find documents where the field specified contains any non-null value. |
25
|
|
|
* |
26
|
|
|
* - "missing" query |
27
|
|
|
* Find documents where the field specified does is missing or contains only null values. |
28
|
|
|
* |
29
|
|
|
* - "prefix" query |
30
|
|
|
* Find documents where the field specified contains terms which being with the exact prefix specified. |
31
|
|
|
* |
32
|
|
|
* - "wildcard" query |
33
|
|
|
* Find documents where the field specified contains terms which match the pattern specified, where the pattern supports |
34
|
|
|
* single character wildcards (?) and multi-character wildcards (*) |
35
|
|
|
* |
36
|
|
|
* - "regexp" query |
37
|
|
|
* Find documents where the field specified contains terms which match the regular expression specified. |
38
|
|
|
* |
39
|
|
|
* - "fuzzy" query |
40
|
|
|
* Find documents where the field specified contains terms which are fuzzily similar to the specified term. |
41
|
|
|
* Fuzziness is measured as a Levenshtein edit distance of 1 or 2. |
42
|
|
|
* |
43
|
|
|
* - "type" query |
44
|
|
|
* Find documents of the specified type. |
45
|
|
|
* |
46
|
|
|
* - "ids" query |
47
|
|
|
* Find documents with the specified type and IDs. |
48
|
|
|
* |
49
|
|
|
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/term-level-queries.html |
50
|
|
|
*/ |
51
|
|
|
abstract class AbstractQuery extends QueryDSL |
52
|
|
|
{ |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @var string |
56
|
|
|
*/ |
57
|
|
|
protected $field; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @return string |
61
|
|
|
*/ |
62
|
|
|
public function getField() |
63
|
|
|
{ |
64
|
|
|
return $this->field; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @param string $field |
69
|
|
|
* |
70
|
|
|
* @return $this |
71
|
|
|
*/ |
72
|
|
|
public function setField($field) |
73
|
|
|
{ |
74
|
|
|
$this->field = $field; |
75
|
|
|
|
76
|
|
|
return $this; |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|