mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-16 15:21:13 +08:00
Query::filter() adjustments
This commit is contained in:
@ -92,7 +92,7 @@ class Query extends Component implements QueryInterface
|
||||
* @var array|string The filter part of this search query. This is an array or json string that follows the format of
|
||||
* the elasticsearch [Query DSL](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl.html).
|
||||
*/
|
||||
public $filter;
|
||||
public $filterPart;
|
||||
|
||||
public $facets = [];
|
||||
|
||||
@ -459,9 +459,9 @@ class Query extends Component implements QueryInterface
|
||||
* @param string $filter
|
||||
* @return static the query object itself
|
||||
*/
|
||||
public function applyFilter($filter)
|
||||
public function filterPart($filter)
|
||||
{
|
||||
$this->filter = $filter;
|
||||
$this->filterPart = $filter;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -62,17 +62,17 @@ class QueryBuilder extends \yii\base\Object
|
||||
}
|
||||
|
||||
$whereFilter = $this->buildCondition($query->where);
|
||||
if (is_string($query->filter)) {
|
||||
if (is_string($query->filterPart)) {
|
||||
if (empty($whereFilter)) {
|
||||
$parts['filter'] = $query->filter;
|
||||
$parts['filter'] = $query->filterPart;
|
||||
} else {
|
||||
$parts['filter'] = '{"and": [' . $query->filter . ', ' . Json::encode($whereFilter) . ']}';
|
||||
$parts['filter'] = '{"and": [' . $query->filterPart . ', ' . Json::encode($whereFilter) . ']}';
|
||||
}
|
||||
} elseif ($query->filter !== null) {
|
||||
} elseif ($query->filterPart !== null) {
|
||||
if (empty($whereFilter)) {
|
||||
$parts['filter'] = $query->filter;
|
||||
$parts['filter'] = $query->filterPart;
|
||||
} else {
|
||||
$parts['filter'] = ['and' => [$query->filter, $whereFilter]];
|
||||
$parts['filter'] = ['and' => [$query->filterPart, $whereFilter]];
|
||||
}
|
||||
} elseif (!empty($whereFilter)) {
|
||||
$parts['filter'] = $whereFilter;
|
||||
|
Reference in New Issue
Block a user