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