Cake\ElasticSearch\Query::where PHP Method

where() public method

There are several way in which you can use this method. The easiest one is by passing a simple array of conditions: {{{ Generates a {"term": {"name": "jose"}} json filter $query->where(['name' => 'jose']); }}} You can have as many conditions in the array as you'd like, Operators are also allowe in the field side of the array: {{{ $query->where(['name' => 'jose', 'age >' => 30, 'interests in' => ['php', 'cake']); }}} You can read about the available operators and how they translate to Elastic Search filters in the Cake\ElasticSearch\FilterBuilder::parse() method documentation. Additionally, it is possible to use a closure as first argument. The closure will receive a FilterBuilder instance, that you can use for creating arbitrary filter combinations: {{{ $query->where(function ($builder) { return $builder->and($builder->between('age', 10, 20), $builder->missing('name')); }); }}} Finally, you can pass any already built filters as first argument: {{{ $query->where(new \Elastica\Filter\Term('name.first', 'jose')); }}{
See also: Cake\ElasticSearch\FilterBuilder
public where ( array | callable | Elastica\Filter\AbstractFilter $conditions, boolean $overwrite = false )
$conditions array | callable | Elastica\Filter\AbstractFilter The list of conditions.
$overwrite boolean Whether or not to replace previous filters.
    public function where($conditions, $overwrite = false)
    {
        return $this->_buildFilter('preFilter', $conditions, $overwrite);
    }