ES 中多條件查詢 匹配


近期使用ES做關聯查詢,實現 a and b and (c1 or c2)and (d1 or d2)的方法 被should 和must搞得暈頭轉向,后仔細拜讀使用說明實現: 

GET gather-034-20171225/_search { "query": { "bool": { "must": [ {"range": { "recive_time": { "gte": "2017-12-25T01:00:00.000Z", "lte": "2017-12-25T02:10:00.000Z" } }}, { "bool": { "should": [ {"range": { "live_delay": { "gte": 1500 } }}, { "range": { "stream_break_count.keyword": { "gte": 1 } } },
] } },
     {
       "bool": { "should": [     {'term': {'status': {'value': 400}}},
        {'term': {'status': {'value': 500}}}

] } }
] } } } 這個中,must的兩個條件都必須滿足,should中的兩個條件至少滿足一個就可以。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM