Wildcard.php 994 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace Elastica\Query;
  3. /**
  4. * Wildcard query.
  5. *
  6. * @author Nicolas Ruflin <spam@ruflin.com>
  7. *
  8. * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-wildcard-query.html
  9. */
  10. class Wildcard extends AbstractQuery
  11. {
  12. /**
  13. * Construct wildcard query.
  14. *
  15. * @param string $key OPTIONAL Wildcard key
  16. * @param string $value OPTIONAL Wildcard value
  17. * @param float $boost OPTIONAL Boost value (default = 1)
  18. */
  19. public function __construct($key = '', $value = null, $boost = 1.0)
  20. {
  21. if (!empty($key)) {
  22. $this->setValue($key, $value, $boost);
  23. }
  24. }
  25. /**
  26. * Sets the query expression for a key with its boost value.
  27. *
  28. * @param string $key
  29. * @param string $value
  30. * @param float $boost
  31. *
  32. * @return $this
  33. */
  34. public function setValue($key, $value, $boost = 1.0)
  35. {
  36. return $this->setParam($key, ['value' => $value, 'boost' => $boost]);
  37. }
  38. }