1<?php
2
3namespace Elastica\Query;
4
5/**
6 * Range query.
7 *
8 * @author Nicolas Ruflin <spam@ruflin.com>
9 *
10 * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-range-query.html
11 */
12class Range extends AbstractQuery
13{
14    /**
15     * Constructor.
16     *
17     * @param string|null $fieldName Field name
18     * @param array       $args      Field arguments
19     */
20    public function __construct(?string $fieldName = null, array $args = [])
21    {
22        if ($fieldName) {
23            $this->addField($fieldName, $args);
24        }
25    }
26
27    /**
28     * Adds a range field to the query.
29     *
30     * @param string $fieldName Field name
31     * @param array  $args      Field arguments
32     *
33     * @return $this
34     */
35    public function addField(string $fieldName, array $args): self
36    {
37        return $this->setParam($fieldName, $args);
38    }
39}
40