Skip to content

Commit 8980145

Browse files
committed
Fix query dsl inconsistency
1 parent 1add0ae commit 8980145

File tree

1 file changed

+41
-28
lines changed

1 file changed

+41
-28
lines changed

lib/Elastica/QueryBuilder/DSL/Query.php

+41-28
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,13 @@ public function custom_boost_factor()
160160
*
161161
* @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-constant-score-query.html
162162
*
163+
* @param null|\Elastica\Filter\AbstractFilter|array $filter
164+
*
163165
* @return ConstantScore
164166
*/
165-
public function constant_score()
167+
public function constant_score($filter = null)
166168
{
167-
return new ConstantScore();
169+
return new ConstantScore($filter);
168170
}
169171

170172
/**
@@ -199,7 +201,7 @@ public function field()
199201
*
200202
* @return Filtered
201203
*/
202-
public function filtered(AbstractQuery $query, AbstractFilter $filter)
204+
public function filtered(AbstractQuery $query = null, AbstractFilter $filter = null)
203205
{
204206
return new Filtered($query, $filter);
205207
}
@@ -243,11 +245,14 @@ public function function_score()
243245
*
244246
* @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-fuzzy-query.html
245247
*
248+
* @param string $fieldName Field name
249+
* @param string $value String to search for
250+
*
246251
* @return Fuzzy
247252
*/
248-
public function fuzzy()
253+
public function fuzzy($fieldName = null, $value = null)
249254
{
250-
return new Fuzzy();
255+
return new Fuzzy($fieldName, $value);
251256
}
252257

253258
/**
@@ -265,12 +270,12 @@ public function geo_shape()
265270
*
266271
* @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-has-child-query.html
267272
*
268-
* @param AbstractQuery $query
269-
* @param null|string $type
273+
* @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query
274+
* @param string $type Parent document type
270275
*
271276
* @return HasChild
272277
*/
273-
public function has_child(AbstractQuery $query, $type = null)
278+
public function has_child($query, $type = null)
274279
{
275280
return new HasChild($query, $type);
276281
}
@@ -280,12 +285,12 @@ public function has_child(AbstractQuery $query, $type = null)
280285
*
281286
* @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-has-parent-query.html
282287
*
283-
* @param AbstractQuery $query
284-
* @param string $type
288+
* @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query
289+
* @param string $type Parent document type
285290
*
286291
* @return HasParent
287292
*/
288-
public function has_parent(AbstractQuery $query, $type)
293+
public function has_parent($query, $type)
289294
{
290295
return new HasParent($query, $type);
291296
}
@@ -300,7 +305,7 @@ public function has_parent(AbstractQuery $query, $type)
300305
*
301306
* @return Ids
302307
*/
303-
public function ids($type, array $ids)
308+
public function ids($type = null, array $ids = array())
304309
{
305310
return new Ids($type, $ids);
306311
}
@@ -367,23 +372,27 @@ public function nested()
367372
*
368373
* @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-prefix-query.html
369374
*
375+
* @param array $prefix Prefix array
376+
*
370377
* @return Prefix
371378
*/
372-
public function prefix()
379+
public function prefix(array $prefix = array())
373380
{
374-
return new Prefix();
381+
return new Prefix($prefix);
375382
}
376383

377384
/**
378385
* query string query.
379386
*
380387
* @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html
381388
*
389+
* @param string $queryString OPTIONAL Query string for object
390+
*
382391
* @return QueryString
383392
*/
384-
public function query_string()
393+
public function query_string($queryString = '')
385394
{
386-
return new QueryString();
395+
return new QueryString($queryString);
387396
}
388397

389398
/**
@@ -411,25 +420,25 @@ public function simple_query_string($query, array $fields = array())
411420
*
412421
* @return Range
413422
*/
414-
public function range($fieldName, array $args)
423+
public function range($fieldName = null, array $args = array())
415424
{
416425
return new Range($fieldName, $args);
417426
}
418427

419428
/**
420429
* regexp query.
421430
*
422-
* @param string $fieldName
431+
* @param string $key
423432
* @param string $value
424433
* @param float $boost
425434
*
426435
* @return Regexp
427436
*
428437
* @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-regexp-query.html
429438
*/
430-
public function regexp($fieldName, $value, $boost)
439+
public function regexp($key = '', $value = null, $boost = 1.0)
431440
{
432-
return new Regexp($fieldName, $value, $boost);
441+
return new Regexp($key, $value, $boost);
433442
}
434443

435444
/**
@@ -511,27 +520,27 @@ public function term(array $term = array())
511520
*
512521
* @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-query.html
513522
*
514-
* @param string $field
523+
* @param string $key
515524
* @param array $terms
516525
*
517526
* @return Terms
518527
*/
519-
public function terms($field, array $terms)
528+
public function terms($key = '', array $terms = array())
520529
{
521-
return new Terms($field, $terms);
530+
return new Terms($key, $terms);
522531
}
523532

524533
/**
525534
* top children query.
526535
*
527536
* @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-top-children-query.html
528537
*
529-
* @param AbstractQuery $query
530-
* @param string $type
538+
* @param string|AbstractQuery|\Elastica\Query $query
539+
* @param string $type
531540
*
532541
* @return TopChildren
533542
*/
534-
public function top_children(AbstractQuery $query, $type)
543+
public function top_children($query, $type = null)
535544
{
536545
return new TopChildren($query, $type);
537546
}
@@ -541,11 +550,15 @@ public function top_children(AbstractQuery $query, $type)
541550
*
542551
* @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-wildcard-query.html
543552
*
553+
* @param string $key OPTIONAL Wildcard key
554+
* @param string $value OPTIONAL Wildcard value
555+
* @param float $boost OPTIONAL Boost value (default = 1)
556+
*
544557
* @return Wildcard
545558
*/
546-
public function wildcard()
559+
public function wildcard($key = '', $value = null, $boost = 1.0)
547560
{
548-
return new Wildcard();
561+
return new Wildcard($key, $value, $boost);
549562
}
550563

551564
/**

0 commit comments

Comments
 (0)