1 | <?php |
||
5 | class QueryBuilder |
||
6 | { |
||
7 | /** |
||
8 | * Query. |
||
9 | * |
||
10 | * @var array |
||
11 | */ |
||
12 | protected $query = []; |
||
13 | |||
14 | /** |
||
15 | * Constructor. |
||
16 | * |
||
17 | * @param array $body |
||
18 | */ |
||
19 | public function __construct(array $body = []) |
||
23 | |||
24 | /** |
||
25 | * @param int $from |
||
26 | * @return $this |
||
27 | */ |
||
28 | public function from($from) |
||
33 | |||
34 | /** |
||
35 | * @param int $size |
||
36 | * @return $this |
||
37 | */ |
||
38 | public function size($size) |
||
43 | |||
44 | /** |
||
45 | * @return bool |
||
46 | */ |
||
47 | public function hasSort() |
||
51 | |||
52 | /** |
||
53 | * @param array|string $sort |
||
54 | * @return $this |
||
55 | */ |
||
56 | public function sort($sort) |
||
61 | |||
62 | /** |
||
63 | * @param array|Filter $filter |
||
64 | * @param string $mode |
||
65 | * @return $this |
||
66 | */ |
||
67 | public function filter($filter = [], $mode = 'include') |
||
89 | |||
90 | /** |
||
91 | * Specify the fields that will be retrieved when searching. |
||
92 | * |
||
93 | * @param mixed $fields |
||
94 | * @return $this |
||
95 | */ |
||
96 | public function fields($fields = false) |
||
107 | |||
108 | /** |
||
109 | * Return only ids. |
||
110 | * |
||
111 | * @return $this |
||
112 | */ |
||
113 | public function getOnlyIds() |
||
117 | |||
118 | /** |
||
119 | * Return query. |
||
120 | * |
||
121 | * @return array |
||
122 | */ |
||
123 | protected function getQuery() |
||
127 | |||
128 | /** |
||
129 | * Build query. |
||
130 | * |
||
131 | * @return array |
||
132 | */ |
||
133 | public function build() |
||
137 | |||
138 | /** |
||
139 | * @return string |
||
140 | */ |
||
141 | public function __toString() |
||
145 | |||
146 | /** |
||
147 | * @return string |
||
148 | */ |
||
149 | public function toJson() |
||
153 | |||
154 | protected function merge(array $query, $mode = 'must') |
||
163 | |||
164 | public function aggregation(Aggregation $aggregation) |
||
169 | |||
170 | public function where($field, $value) |
||
176 | |||
177 | public function notWhere($field, $value) |
||
183 | |||
184 | public function orWhere($field, $value) |
||
190 | |||
191 | public function between($field, $start, $end) |
||
197 | |||
198 | public function betweenOrEquals($field, $start, $end) |
||
204 | |||
205 | public function range($field, $start, $end) |
||
209 | |||
210 | public function greaterThan($field, $start) |
||
216 | |||
217 | public function gt($field, $start) |
||
221 | |||
222 | public function greaterThanOrEquals($field, $start) |
||
228 | |||
229 | public function gte($field, $start) |
||
233 | |||
234 | public function lessThan($field, $end) |
||
240 | |||
241 | public function lt($field, $start) |
||
245 | |||
246 | public function lessThanOrEquals($field, $end) |
||
252 | |||
253 | public function lte($field, $start) |
||
257 | |||
258 | public function match($field, $value) |
||
264 | |||
265 | public function notMatch($field, $value) |
||
271 | |||
272 | public function orMatch($field, $value) |
||
278 | } |