How to make a WHERE categoryId = 1 OR categoryId = 2
query with Elastica
? I'm doing this but I got 0 result
:
$query = new \Elastica\Query();
$boolOr = new \Elastica\Filter\BoolOr();
$boolOr->addFilter(new \Elastica\Filter\Term(array('categoryId' => '1')));
$boolOr->addFilter(new \Elastica\Filter\Term(array('categoryId' => '2')));
$filtered = new \Elastica\Query\Filtered(new \Elastica\Query\MatchAll(), $boolOr);
$query->setQuery($filtered);
$products = $type->search($query)->getResults();
Here is a working example:
You don't need to use the filtered and matchall query. The working example can be found here: https://github.com/ruflin/Elastica/pull/887/files