1<?php
2
3namespace Elastica\Query;
4
5/**
6 * Wildcard query.
7 *
8 * @author Nicolas Ruflin <spam@ruflin.com>
9 *
10 * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-wildcard-query.html
11 */
12class Wildcard extends AbstractQuery
13{
14    /**
15     * Construct wildcard query.
16     *
17     * @param string $key   OPTIONAL Wildcard key
18     * @param string $value OPTIONAL Wildcard 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 (!empty($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     * @param string $key
32     * @param string $value
33     * @param float  $boost
34     *
35     * @return $this
36     */
37    public function setValue(string $key, string $value, float $boost = 1.0): self
38    {
39        return $this->setParam($key, ['value' => $value, 'boost' => $boost]);
40    }
41}
42