|null $shape Inline GeoJSON shape; null when $indexedShape is used.
*/
public function __construct(
private string $field,
private array|null $shape = null,
private string $relation = 'intersects',
private bool|null $ignoreUnmapped = null,
private \Spameri\ElasticQuery\Query\IndexedShape|null $indexedShape = null,
private float $boost = 1.0,
)
{
if ( ! \in_array($relation, ['intersects', 'disjoint', 'within', 'contains'], true)) {
throw new \Spameri\ElasticQuery\Exception\InvalidArgumentException(
'Shape relation must be one of: intersects, disjoint, within, contains.',
);
}
if ($shape === null && $indexedShape === null) {
throw new \Spameri\ElasticQuery\Exception\InvalidArgumentException(
'Shape requires either an inline shape or an indexedShape.',
);
}
}
public function key(): string
{
return 'shape_' . $this->field;
}
/**
* @return array