开发者社区> 问答> 正文

elasticsearch 的and or怎样用?报错

{  
    "query": {  
        "filtered": {  
            "query" : {  
                "match_all":{}  
            },  
            "filter" : {  
   "and": [
       {
           "term": {"queue_id": "1"}
       }, 
       {
           "or": [
                {"terms": {"case_number": [ "75-717", "75-718"]}}, 
                {"term": {"entered_by_email": "system" } }
            ]
       }
    ]
            }  
        }  
    },  
     "sort": { "case_summary.keyword": { "order": "desc" }}
}  

 

执行请求,总是报错 {
    "error": {
        "root_cause": [
            {
                "type": "parsing_exception",
                "reason": "no [query] registered for [filtered]",
                "line": 4,
                "col": 21
            }
        ],
        "type": "parsing_exception",
        "reason": "no [query] registered for [filtered]",
        "line": 4,
        "col": 21
    },
    "status": 400
}

这是怎么回事,求解答,谢谢

展开
收起
爱吃鱼的程序员 2020-06-07 18:33:59 409 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB
                        <p>应该是elasticsearch版本的原因,filtered被废弃了,and, or也不再用了。</p> 
    
    {
      "query": {
        "bool": {
          "filter": {
            "bool": {
              "must": [
                { "term": { "queue_id":"1"} },
                {
                  "bool": {
                    "should": [
                      { "term": {"case_number":"75-717"},   
                      { "term": {"case_number":"75-718"},
                      { "term": {"entered_by_email":"system"}
                    ]
                }
              }
            }
          }
        }
      },
      "sort": {
        "case_summary.keyword": {
          "order":"desc"
        }
      }
    }              

     

    2020-06-07 18:34:19
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
阿里云Elasticsearch体系架构与特性解析 立即下载
开源与云:Elasticsearch应用剖析 立即下载
《Elasticsearch全观测解决方案》 立即下载