$fields
*/
public function __construct(
private string $query,
private array $fields = [],
private string|null $defaultOperator = null,
private string|null $analyzer = null,
private string|null $flags = null,
private float $boost = 1.0,
)
{
}
public function key(): string
{
return 'simple_query_string_' . $this->query;
}
/**
* @return array>
*/
public function toArray(): array
{
$body = [
'query' => $this->query,
'boost' => $this->boost,
];
if ($this->fields !== []) {
$body['fields'] = $this->fields;
}
if ($this->defaultOperator !== null) {
$body['default_operator'] = $this->defaultOperator;
}
if ($this->analyzer !== null) {
$body['analyzer'] = $this->analyzer;
}
if ($this->flags !== null) {
$body['flags'] = $this->flags;
}
return [
'simple_query_string' => $body,
];
}
}