Commit e5ba8c87 by Carsten Brandt

reverted elasticsearch rename of filter

parent 36c59dce
...@@ -92,10 +92,11 @@ class Query extends Component implements QueryInterface ...@@ -92,10 +92,11 @@ 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 * @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). * the elasticsearch [Query DSL](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl.html).
*/ */
public $filterPart; public $filter;
public $facets = []; public $facets = [];
public function init() public function init()
{ {
parent::init(); parent::init();
...@@ -271,7 +272,6 @@ class Query extends Component implements QueryInterface ...@@ -271,7 +272,6 @@ class Query extends Component implements QueryInterface
foreach ($result['hits']['hits'] as $row) { foreach ($result['hits']['hits'] as $row) {
$column[] = isset($row['fields'][$field]) ? $row['fields'][$field] : null; $column[] = isset($row['fields'][$field]) ? $row['fields'][$field] : null;
} }
return $column; return $column;
} }
...@@ -316,7 +316,6 @@ class Query extends Component implements QueryInterface ...@@ -316,7 +316,6 @@ class Query extends Component implements QueryInterface
public function addFacet($name, $type, $options) public function addFacet($name, $type, $options)
{ {
$this->facets[$name] = [$type => $options]; $this->facets[$name] = [$type => $options];
return $this; return $this;
} }
...@@ -450,7 +449,6 @@ class Query extends Component implements QueryInterface ...@@ -450,7 +449,6 @@ class Query extends Component implements QueryInterface
public function query($query) public function query($query)
{ {
$this->query = $query; $this->query = $query;
return $this; return $this;
} }
...@@ -459,10 +457,9 @@ class Query extends Component implements QueryInterface ...@@ -459,10 +457,9 @@ class Query extends Component implements QueryInterface
* @param string $filter * @param string $filter
* @return static the query object itself * @return static the query object itself
*/ */
public function filterPart($filter) public function filter($filter)
{ {
$this->filterPart = $filter; $this->filter = $filter;
return $this; return $this;
} }
...@@ -479,7 +476,6 @@ class Query extends Component implements QueryInterface ...@@ -479,7 +476,6 @@ class Query extends Component implements QueryInterface
{ {
$this->index = $index; $this->index = $index;
$this->type = $type; $this->type = $type;
return $this; return $this;
} }
...@@ -496,7 +492,6 @@ class Query extends Component implements QueryInterface ...@@ -496,7 +492,6 @@ class Query extends Component implements QueryInterface
} else { } else {
$this->fields = func_get_args(); $this->fields = func_get_args();
} }
return $this; return $this;
} }
...@@ -510,7 +505,6 @@ class Query extends Component implements QueryInterface ...@@ -510,7 +505,6 @@ class Query extends Component implements QueryInterface
public function timeout($timeout) public function timeout($timeout)
{ {
$this->timeout = $timeout; $this->timeout = $timeout;
return $this; return $this;
} }
} }
...@@ -62,17 +62,17 @@ class QueryBuilder extends \yii\base\Object ...@@ -62,17 +62,17 @@ class QueryBuilder extends \yii\base\Object
} }
$whereFilter = $this->buildCondition($query->where); $whereFilter = $this->buildCondition($query->where);
if (is_string($query->filterPart)) { if (is_string($query->filter)) {
if (empty($whereFilter)) { if (empty($whereFilter)) {
$parts['filter'] = $query->filterPart; $parts['filter'] = $query->filter;
} else { } else {
$parts['filter'] = '{"and": [' . $query->filterPart . ', ' . Json::encode($whereFilter) . ']}'; $parts['filter'] = '{"and": [' . $query->filter . ', ' . Json::encode($whereFilter) . ']}';
} }
} elseif ($query->filterPart !== null) { } elseif ($query->filter !== null) {
if (empty($whereFilter)) { if (empty($whereFilter)) {
$parts['filter'] = $query->filterPart; $parts['filter'] = $query->filter;
} else { } else {
$parts['filter'] = ['and' => [$query->filterPart, $whereFilter]]; $parts['filter'] = ['and' => [$query->filter, $whereFilter]];
} }
} elseif (!empty($whereFilter)) { } elseif (!empty($whereFilter)) {
$parts['filter'] = $whereFilter; $parts['filter'] = $whereFilter;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment