1<?php
2
3namespace Elastica\Query;
4
5/**
6 * Constant score query.
7 *
8 * @author Nicolas Ruflin <spam@ruflin.com>
9 *
10 * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-constant-score-query.html
11 */
12class ConstantScore extends AbstractQuery
13{
14    /**
15     * Construct constant score query.
16     *
17     * @param AbstractQuery|null $filter
18     */
19    public function __construct(AbstractQuery $filter = null)
20    {
21        if (null !== $filter) {
22            $this->setFilter($filter);
23        }
24    }
25
26    /**
27     * Set filter.
28     *
29     * @param AbstractQuery $filter
30     *
31     * @return $this
32     */
33    public function setFilter(AbstractQuery $filter): self
34    {
35        return $this->setParam('filter', $filter);
36    }
37
38    /**
39     * Set boost.
40     *
41     * @param float $boost
42     *
43     * @return $this
44     */
45    public function setBoost(float $boost): self
46    {
47        return $this->setParam('boost', $boost);
48    }
49}
50