Nested.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace Elastica\Query;
  3. /**
  4. * Nested query.
  5. *
  6. * @author Nicolas Ruflin <spam@ruflin.com>
  7. *
  8. * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-nested-query.html
  9. */
  10. class Nested extends AbstractQuery
  11. {
  12. /**
  13. * Adds field to mlt query.
  14. *
  15. * @param string $path Nested object path
  16. *
  17. * @return $this
  18. */
  19. public function setPath($path)
  20. {
  21. return $this->setParam('path', $path);
  22. }
  23. /**
  24. * Sets nested query.
  25. *
  26. * @param \Elastica\Query\AbstractQuery $query
  27. *
  28. * @return $this
  29. */
  30. public function setQuery(AbstractQuery $query)
  31. {
  32. return $this->setParam('query', $query);
  33. }
  34. /**
  35. * Set score method.
  36. *
  37. * @param string $scoreMode options: avg, total, max and none
  38. *
  39. * @return $this
  40. */
  41. public function setScoreMode($scoreMode)
  42. {
  43. return $this->setParam('score_mode', $scoreMode);
  44. }
  45. /**
  46. * Set inner hits.
  47. *
  48. * @param InnerHits $innerHits
  49. *
  50. * @return $this
  51. */
  52. public function setInnerHits(InnerHits $innerHits)
  53. {
  54. return $this->setParam('inner_hits', $innerHits);
  55. }
  56. }