How to apply filters in elastica library which works with elastic search.
Need an example of term filters.
$query1 = new \Elastica\Filter\Term();
$query1->setTerm('categories', array('short_description' =>'test metal'));
$bool->addShould($query);
or
$query1 = new \Elastica\Filter\Term();
$query1->setTerm('categories', 'test metal');
I am trying to use above ways which is resulting in following error
Invalid parameter. Has to be array or instance of Elastica\Query\AbstractQuery
Filters are deprecated. Use queries in filter context.
For example:
EDIT: @Sattu I'm using Elastica too. It depends which version of Elastica you have. If you have v3.2.3 you have to use raw query. Something like this:
But if you have Elastica v5 you can use Elastica\Query class and set filter through
addFilter()
method.