如何使用AND和OR逻辑组合查询嵌套对象?

时间:2017-10-06 10:00:03

标签: elasticsearch

如何将此表达式编写为查询:

(attributes.id = 14 OR attributes.id = 15)AND(attributes.id = 4843 OR attributes.id = 4859)

嵌套对象如下所示:

$page->add_admin_page()

我尝试过使用这个查询 - 很多 - 没有任何运气:

add_menu_page

上述查询返回零结果。

任何帮助都将不胜感激。

2 个答案:

答案 0 :(得分:1)

{  
  "query":{  
   "nested":{  
  "path":"attributes",
  "query":{  
    "bool":{  
      "must":[{
        "bool": {
            "should": [
               {
                   "term": {
                      "attributes.id": 14
                   }
               },{
                   "term": {
                      "attributes.id": 15
                   }
               }
            ]
        }
      },{
        "bool": {
            "should": [
               {
                   "term": {
                      "attributes.id": 4843
                   }
               },{
                   "term": {
                      "attributes.id": 4859
                   }
               }
            ]
        }
      }
      ]
  }
}

}

这应该有用。

答案 1 :(得分:0)

我在Elastic Stack by Daniel_Penning上得到了答案:

select
    table1.EmpName as "Employee",
    table1.weekof as "Week Of",
    t2.pph as "Previous PPH",
    table1.pph as "Current PPH",
    table1.quality as "Quality"
from table1 t2
join
table1 on t2.EmpName = table1.EmpName
where t2.weekof = '9/11/2017' and table1.weekof = '9/18/2017'