[英]Elasticsearch (PHP) multiple range filters issue
I am pretty new to Elasticsearch, so apologies if this is is an obvious question! 我对Elasticsearch很新,所以如果这是一个显而易见的问题,请道歉!
I am using the PHP library and trying to do a pretty straightforward query across an index. 我正在使用PHP库并试图在索引中进行非常简单的查询。 The only thing I wanted to do was perform a filter against two dates (visible_from and visible_to) which I have set to date types when creating the mapping.
我唯一想做的就是对两个日期(visible_from和visible_to)执行过滤,我在创建映射时将其设置为日期类型。
I am building up a filtered query in the code, which ends up looking like this: 我在代码中构建了一个过滤的查询,最终看起来像这样:
array (
'index' => 'site',
'from' => 0,
'size' => 10,
'body' =>
array (
'query' =>
array (
'filtered' =>
array (
'filter' =>
array (
'and' =>
array (
'range' =>
array (
'visible_from' =>
array (
'lt' => '2014-06-09 09:06:47',
),
'visible_to' =>
array (
'gt' => '2014-06-09 09:06:47',
),
),
),
),
'query' =>
array (
'match' =>
array (
'_all' => 'example',
),
),
),
),
),
)
This results in a BadRequest400Exception being thrown - in the content of the exception I can see that Elasticssearch is saying 这会导致抛出BadRequest400Exception - 在异常的内容中我可以看到Elasticssearch在说
QueryParsingException[[site] [and] filter does not support [lt]]
If I remove the AND filter and just perform the range filter against one of the dates, then it works perfectly, I am just unable to get it working with the AND filter 如果我删除AND过滤器并只针对其中一个日期执行范围过滤器,那么它完美地工作,我只是无法使用AND过滤器
Thanks in advance for any help! 在此先感谢您的帮助!
Make a try with below query, Try with different less than and greater than date. 尝试下面的查询,尝试使用不同于小于和大于日期。
array
(
"query" => array
(
"filtered" => array
(
"query" => array
(
"match" => array(
'_all' => 'example',
),
),
"filter" => array
(
"and" => array
(
"filters" => array
(
"0" => array
(
"range" => array
(
"ID" => array
(
"gt" => '2014-06-09 09:06:47',
),
),
),
"1" => array
(
"range" => array
(
"ID" => array
(
"lt" => '2014-06-09 09:06:47',
),
),
),
),
),
),
),
),
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.