1<?php
2
3namespace Elastica\Query;
4
5/**
6 * Regexp query.
7 *
8 * @author Aurélien Le Grand <gnitg@yahoo.fr>
9 *
10 * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-regexp-query.html
11 */
12class Regexp extends AbstractQuery
13{
14    /**
15     * Construct regexp query.
16     *
17     * @param string      $key   OPTIONAL Regexp key
18     * @param string|null $value OPTIONAL Regexp value
19     * @param float       $boost OPTIONAL Boost value (default = 1)
20     */
21    public function __construct(string $key = '', ?string $value = null, float $boost = 1.0)
22    {
23        if ('' !== $key) {
24            $this->setValue($key, $value, $boost);
25        }
26    }
27
28    /**
29     * Sets the query expression for a key with its boost value.
30     *
31     * @return $this
32     */
33    public function setValue(string $key, ?string $value = null, float $boost = 1.0)
34    {
35        return $this->setParam($key, ['value' => $value, 'boost' => $boost]);
36    }
37}
38