Boosting.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace Elastica\Query;
  3. /**
  4. * Class Boosting.
  5. *
  6. * @author Balazs Nadasdi <yitsushi@gmail.com>
  7. *
  8. * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-boosting-query.html
  9. */
  10. class Boosting extends AbstractQuery
  11. {
  12. const NEGATIVE_BOOST = 0.2;
  13. /**
  14. * Set the positive query for this Boosting Query.
  15. *
  16. * @param AbstractQuery $query
  17. *
  18. * @return $this
  19. */
  20. public function setPositiveQuery(AbstractQuery $query)
  21. {
  22. return $this->setParam('positive', $query);
  23. }
  24. /**
  25. * Set the negative query for this Boosting Query.
  26. *
  27. * @param AbstractQuery $query
  28. *
  29. * @return $this
  30. */
  31. public function setNegativeQuery(AbstractQuery $query)
  32. {
  33. return $this->setParam('negative', $query);
  34. }
  35. /**
  36. * Set the negative_boost parameter for this Boosting Query.
  37. *
  38. * @param float $negativeBoost
  39. *
  40. * @return $this
  41. */
  42. public function setNegativeBoost($negativeBoost)
  43. {
  44. return $this->setParam('negative_boost', (float) $negativeBoost);
  45. }
  46. }