Elastica PHP filter multiple values for the same field

I'm not able to use Elastica to filter multiple values for the same field.

Single value for a field works :

$filtre = array();
array_push($filtre, $qb->filter()->term(array('id' => '60')));
$elastica_query->setQuery(
			$qb->query()->filtered(
				$qb->query()->match_all(),
				 $qb->filter()->bool()->addMust($filtre)
			)
		) 

Which gives me the wanted result. But when I try to add another value for the same field, there are no results showing.

$filtre = array();
array_push($filtre, $qb->filter()->term(array('id' => '60')));
array_push($filtre, $qb->filter()->term(array('id' => '87')));
$elastica_query->setQuery(
			$qb->query()->filtered(
				$qb->query()->match_all(),
				 $qb->filter()->bool()->addMust($filtre)
			)
		) 

What am I doing wrong ?
PS : If I add filters for other fields, everything works fine, but just adding a second value for any field doesn't work.

Can you try to print the output of $elsatica_query->toArray() with only 1 value and with both values? I assume what happens is that the values are overwritten.

Which version of Elastica are you using?

@ruflin he figured it out over here: https://stackoverflow.com/questions/49915214/elastica-php-cant-filter-multiple-values-for-the-same-field :wink:

@val Thanks for the heads up.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.