简体   繁体   English

如何使用Elasticsearch 1.4.5中必须使用范围和术语进行过滤的方法

[英]How to use must filter with range and terms in elasticsearch 1.4.5

I have to find data started from "today" and its "displaystatus" must be zero. 我必须找到从“ today”开始的数据,并且其“ displaystatus”必须为零。 I am using this but it will also returns the documents having displaystatus one. 我正在使用它,但它也会返回显示状态为1的文档。

$searchParams['index'] = 'events';  
$searchParams['type'] = 'couchbaseDocument';  
$searchParams['from'] = 0;  
$searchParams['size'] = 1000;  
$searchParams['body']['query']['filtered']['filter']['bool']['must'][]['range']['starttimestamp']['from'] = $today;  
$searchParams['body']['query']['filtered']['filter']['bool']['must'][]['term']['displaystatus'] = 0;  
$searchParams['body']['query']['filtered']['filter']['bool']['must'][]['terms']['cat_id'] = $interestIdArray;

I am not sure about python but something like this 我不确定python,但是类似这样

{
  "query": {
    "filtered": {

      "filter": {
        "bool": {
          "must": [
            {
              "range": {
                "FIELD": {
                  "gte": ,
                  "lte": 
                }
              }
            },
            {
              "term": {
                "FIELD": "VALUE"
              }
            },
            {
              "term": {
                "FIELD": "VALUE"
              }
            }
          ]
        }
      }
    }
  }
}

should work in marvel. 应该惊叹不已。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM