1<?php
2
3namespace Elastica\Collapse;
4
5use Elastica\Collapse;
6use Elastica\Query\InnerHits as BaseInnerHits;
7
8/**
9 * Class InnerHits.
10 *
11 * Basically identical to inner_hits on query level, but has support for a second level collapse as per
12 * https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html#_second_level_of_collapsing
13 *
14 * Collapse is part of the inner_hits construct in this case, which should be explicitly supported and not only
15 * via calling InnerHits::setParam('collapse', $collapse).
16 *
17 * On the other hand, collapse cannot be used on query level invocations of inner_hits, which is why it may not be part
18 * of Query\InnerHits.
19 */
20class InnerHits extends BaseInnerHits
21{
22    /**
23     * @return $this
24     */
25    public function setCollapse(Collapse $collapse): self
26    {
27        return $this->setParam('collapse', $collapse);
28    }
29}
30