Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/233.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 包括';空';过滤器中的值以及范围过滤器(Elastica)_Php_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch_Elastica - Fatal编程技术网 elasticsearch,elastica,Php,elasticsearch,Elastica" /> elasticsearch,elastica,Php,elasticsearch,Elastica" />

Php 包括';空';过滤器中的值以及范围过滤器(Elastica)

Php 包括';空';过滤器中的值以及范围过滤器(Elastica),php,elasticsearch,elastica,Php,elasticsearch,Elastica,我正在使用Elastica,我需要创建一个过滤器,该过滤器将获得空值以及小于100的值 目前,我的代码如下所示: $this->filter = $qb->query()->bool(); $this->filter->addShould($qb->query()->range('price', ['lte' => 100])); $this->filter->addMustNot($qb->query()->range(

我正在使用Elastica,我需要创建一个过滤器,该过滤器将获得空值以及小于100的值

目前,我的代码如下所示:

$this->filter = $qb->query()->bool();
$this->filter->addShould($qb->query()->range('price', ['lte' => 100]));
$this->filter->addMustNot($qb->query()->range('price', ['gte' => 100]));
它返回价格低于100的数据。 我还需要使用null值获取数据。 到目前为止,我试过:

$this->filter->addMustNot($qb->query()->exists('price')); // returns 0 items
$this->filter->addShould($qb->query()->missing('price')); // doesn't work. Gives undefined query "missing" in Facade.php
有人能帮我解决这个问题吗?或者如何修复未定义查询“丢失”的问题,或者创建另一个符合我需要的过滤器。谢谢。

使用相同的
range()
使其按我需要的方式工作。 看起来是这样的:

$this->filter = $qb->query()->bool();
$this->filter->addShould($qb->query()->range('price', ['lte' => 100]));
$this->filter->addMustNot($qb->query()->range('price', ['gte' => 100]));
我使用的是addMustNot,因此它会过滤与该过滤器匹配的所有值(小于100的所有值都将返回,即使它是null值)