Elastica PHP Query Where Or -
how make where categoryid = 1 or categoryid = 2
query elastica
? i'm doing 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 working example:
$index = $this->_createindex(); $type = $index->gettype('test'); $doc1 = new document('', array('categoryid' => 1)); $doc2 = new document('', array('categoryid' => 2)); $doc3 = new document('', array('categoryid' => 3)); $type->adddocument($doc1); $type->adddocument($doc2); $type->adddocument($doc3); $index->refresh(); $boolor = new \elastica\filter\boolor(); $boolor->addfilter(new \elastica\filter\term(array('categoryid' => '1'))); $boolor->addfilter(new \elastica\filter\term(array('categoryid' => '2'))); $resultset = $type->search($boolor);
you don't need use filtered , matchall query. working example can found here: https://github.com/ruflin/elastica/pull/887/files
Comments
Post a Comment