ConstantScore.php 960 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace Elastica\Query;
  3. /**
  4. * Constant score query.
  5. *
  6. * @author Nicolas Ruflin <spam@ruflin.com>
  7. *
  8. * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-constant-score-query.html
  9. */
  10. class ConstantScore extends AbstractQuery
  11. {
  12. /**
  13. * Construct constant score query.
  14. *
  15. * @param AbstractQuery|array|null $filter
  16. */
  17. public function __construct(AbstractQuery $filter = null)
  18. {
  19. if (!is_null($filter)) {
  20. $this->setFilter($filter);
  21. }
  22. }
  23. /**
  24. * Set filter.
  25. *
  26. * @param array|AbstractQuery $filter
  27. *
  28. * @return $this
  29. */
  30. public function setFilter(AbstractQuery $filter)
  31. {
  32. return $this->setParam('filter', $filter);
  33. }
  34. /**
  35. * Set boost.
  36. *
  37. * @param float $boost
  38. *
  39. * @return $this
  40. */
  41. public function setBoost($boost)
  42. {
  43. return $this->setParam('boost', $boost);
  44. }
  45. }