1
1
<?php
2
+
2
3
namespace Elastica \QueryBuilder \DSL ;
3
4
4
5
use Elastica \Filter \AbstractFilter ;
@@ -62,12 +63,9 @@ public function getType()
62
63
*
63
64
* @return BoolAnd
64
65
*/
65
- public function bool_and (array $ filters )
66
+ public function bool_and (array $ filters = array () )
66
67
{
67
- $ and = new BoolAnd ();
68
- $ and ->setFilters ($ filters );
69
-
70
- return $ and ;
68
+ return new BoolAnd ($ filters );
71
69
}
72
70
73
71
/**
@@ -101,14 +99,14 @@ public function exists($field)
101
99
*
102
100
* @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-bounding-box-filter.html
103
101
*
104
- * @param string $field
102
+ * @param string $key
105
103
* @param array $coordinates
106
104
*
107
105
* @return GeoBoundingBox
108
106
*/
109
- public function geo_bounding_box ($ field , array $ coordinates )
107
+ public function geo_bounding_box ($ key , array $ coordinates )
110
108
{
111
- return new GeoBoundingBox ($ field , $ coordinates );
109
+ return new GeoBoundingBox ($ key , $ coordinates );
112
110
}
113
111
114
112
/**
@@ -197,29 +195,29 @@ public function geo_shape_pre_indexed($path, $indexedId, $indexedType, $indexedI
197
195
*
198
196
* @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geohash-cell-filter.html
199
197
*
200
- * @param string $field The field on which to filter
198
+ * @param string $key The field on which to filter
201
199
* @param array|string $location Location as coordinates array or geohash string ['lat' => 40.3, 'lon' => 45.2]
202
200
* @param int|string $precision length of geohash prefix or distance (3, or "50m")
203
201
* @param bool $neighbors If true, filters cells next to the given cell.
204
202
*
205
203
* @return GeohashCell
206
204
*/
207
- public function geohash_cell ($ field , $ location , $ precision = -1 , $ neighbors = false )
205
+ public function geohash_cell ($ key , $ location , $ precision = -1 , $ neighbors = false )
208
206
{
209
- return new GeohashCell ($ field , $ location , $ precision , $ neighbors );
207
+ return new GeohashCell ($ key , $ location , $ precision , $ neighbors );
210
208
}
211
209
212
210
/**
213
211
* has child filter.
214
212
*
215
213
* @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-has-child-filter.html
216
214
*
217
- * @param AbstractQuery| AbstractFilter $query
218
- * @param string $ type
215
+ * @param string|\Elastica\Query|\Elastica\Filter\ AbstractFilter $query Query string or a Elastica\Query object or a filter
216
+ * @param string|\Elastica\Type $type Child document type
219
217
*
220
218
* @return HasChild
221
219
*/
222
- public function has_child ($ query , $ type )
220
+ public function has_child ($ query , $ type = null )
223
221
{
224
222
return new HasChild ($ query , $ type );
225
223
}
@@ -249,7 +247,7 @@ public function has_parent($query, $type)
249
247
*
250
248
* @return Ids
251
249
*/
252
- public function ids ($ type , array $ ids )
250
+ public function ids ($ type = null , array $ ids = array () )
253
251
{
254
252
return new Ids ($ type , $ ids );
255
253
}
@@ -304,7 +302,7 @@ public function match_all()
304
302
*
305
303
* @return Missing
306
304
*/
307
- public function missing ($ field )
305
+ public function missing ($ field = '' )
308
306
{
309
307
return new Missing ($ field );
310
308
}
@@ -340,11 +338,14 @@ public function bool_not(AbstractFilter $filter)
340
338
*
341
339
* @link http://www.elastic.co/guide/en/elasticsearch/reference/0.90/query-dsl-numeric-range-filter.html
342
340
*
341
+ * @param string $fieldName Field name
342
+ * @param array $args Field arguments
343
+ *
343
344
* @return NumericRange
344
345
*/
345
- public function numeric_range ()
346
+ public function numeric_range ($ fieldName = '' , array $ args = array () )
346
347
{
347
- return new NumericRange ();
348
+ return new NumericRange ($ fieldName , $ args );
348
349
}
349
350
350
351
/**
@@ -356,12 +357,9 @@ public function numeric_range()
356
357
*
357
358
* @return BoolOr
358
359
*/
359
- public function bool_or ($ filters )
360
+ public function bool_or (array $ filters = array () )
360
361
{
361
- $ or = new BoolOr ();
362
- $ or ->setFilters ($ filters );
363
-
364
- return $ or ;
362
+ return new BoolOr ($ filters );
365
363
}
366
364
367
365
/**
@@ -374,7 +372,7 @@ public function bool_or($filters)
374
372
*
375
373
* @return Prefix
376
374
*/
377
- public function prefix ($ field , $ prefix )
375
+ public function prefix ($ field = '' , $ prefix = '' )
378
376
{
379
377
return new Prefix ($ field , $ prefix );
380
378
}
@@ -384,11 +382,11 @@ public function prefix($field, $prefix)
384
382
*
385
383
* @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-filter.html
386
384
*
387
- * @param AbstractQuery $query
385
+ * @param array|\Elastica\Query\ AbstractQuery $query
388
386
*
389
387
* @return QueryFilter
390
388
*/
391
- public function query (AbstractQuery $ query )
389
+ public function query ($ query = null )
392
390
{
393
391
return new QueryFilter ($ query );
394
392
}
@@ -403,7 +401,7 @@ public function query(AbstractQuery $query)
403
401
*
404
402
* @return Range
405
403
*/
406
- public function range ($ fieldName , array $ args )
404
+ public function range ($ fieldName = '' , array $ args = array () )
407
405
{
408
406
return new Range ($ fieldName , $ args );
409
407
}
@@ -413,14 +411,15 @@ public function range($fieldName, array $args)
413
411
*
414
412
* @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-regexp-filter.html
415
413
*
416
- * @param string $field
417
- * @param string $regexp
414
+ * @param string $field Field name
415
+ * @param string $regexp Regular expression
416
+ * @param array $options Regular expression options
418
417
*
419
418
* @return Regexp
420
419
*/
421
- public function regexp ($ field , $ regexp )
420
+ public function regexp ($ field = '' , $ regexp = '' , $ options = array () )
422
421
{
423
- return new Regexp ($ field , $ regexp );
422
+ return new Regexp ($ field , $ regexp, $ options );
424
423
}
425
424
426
425
/**
@@ -432,7 +431,7 @@ public function regexp($field, $regexp)
432
431
*
433
432
* @return Script
434
433
*/
435
- public function script ($ script )
434
+ public function script ($ script = null )
436
435
{
437
436
return new Script ($ script );
438
437
}
@@ -456,14 +455,14 @@ public function term(array $term = array())
456
455
*
457
456
* @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-filter.html
458
457
*
459
- * @param string $field
458
+ * @param string $key
460
459
* @param array $terms
461
460
*
462
461
* @return Terms
463
462
*/
464
- public function terms ($ field , array $ terms )
463
+ public function terms ($ key = '' , array $ terms = array () )
465
464
{
466
- return new Terms ($ field , $ terms );
465
+ return new Terms ($ key , $ terms );
467
466
}
468
467
469
468
/**
@@ -475,7 +474,7 @@ public function terms($field, array $terms)
475
474
*
476
475
* @return Type
477
476
*/
478
- public function type ($ type )
477
+ public function type ($ type = null )
479
478
{
480
479
return new Type ($ type );
481
480
}
0 commit comments