in 6.x
https://github.com/ruflin/Elastica/blob/6.x/lib/Elastica/Query/Terms.php#L53
public function setTerms($key, array $terms)
{
$this->_key = $key;
$this->_terms = array_values($terms);
return $this;
}
in 7.x
https://github.com/ruflin/Elastica/blob/7.x/src/Query/Terms.php#L42
public function setTerms(array $terms): self
{
return $this->setParam($this->field, $terms);
}
public function setParams(array $params)
{
$this->_params = $params;
return $this;
}
Which no longer normalize the array.
In normal usage of regular arrays there's no issue, but when an array elements were removed the terms generated aren't recognized properly by ES and results in failed to parse field error
ex:
$array = array(0, 1, 2, 3);php > $array = [0, 123, 456];;
php > unset($array[0]);
php > var_dump($array);
php shell code:1:
array(2) {
[1] =>
int(123)
[2] =>
int(456)
}
// query output {"1":123,"2":456}
php > var_dump(array_values($array));
php shell code:1:
array(2) {
[0] =>
int(123)
[1] =>
int(456)
}
// query output [123,456]
in 6.x
https://github.com/ruflin/Elastica/blob/6.x/lib/Elastica/Query/Terms.php#L53
in 7.x
https://github.com/ruflin/Elastica/blob/7.x/src/Query/Terms.php#L42
Which no longer normalize the array.
In normal usage of regular arrays there's no issue, but when an array elements were removed the terms generated aren't recognized properly by ES and results in failed to parse field error
ex: