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     * @param AbstractQuery $query
30     *
31     * @return $this
32     */
33    public function setQuery(AbstractQuery $query): self
34    {
35        return $this->setParam('query', $query);
36    }
37
38    /**
39     * Set score method.
40     *
41     * @param string $scoreMode options: avg, total, max and none
42     *
43     * @return $this
44     */
45    public function setScoreMode(string $scoreMode = 'avg'): self
46    {
47        return $this->setParam('score_mode', $scoreMode);
48    }
49
50    /**
51     * Set inner hits.
52     *
53     * @param InnerHits $innerHits
54     *
55     * @return $this
56     */
57    public function setInnerHits(InnerHits $innerHits): self
58    {
59        return $this->setParam('inner_hits', $innerHits);
60    }
61}
62