Elasticsearch 多條件查詢


 

查詢 organization_id 為 208 和 event_type 為 007 的數據

curl -X GET 10.44.99.102:9200/situation-event/_search?pretty -d 
{
    "query": {
        "bool": {
            "must": [{
                "term": {
                    "organization_id": "208"
                }
            }, {
                "term": {
                    "event_type": "007"
                }
            }]
        }
    }
}

 

查詢 organization_id 為 208 和 event_type 為 007 或者 008 的數據

curl -X GET 10.44.99.102:9200/situation-event/_search?pretty -d 
{
    "query": {
        "bool": {
            "must": [{
                "match_phrase": {
                    "organization_id": "208"
                }
            }],
            "should": [{
                    "match_phrase": {
                        "event_type": "007"
                    }
                },
                {
                    "match_phrase": {
                        "event_type": "008"
                    }
                }
            ],
            "minimum_should_match": 1
        }
    }
}

 

  

 1 curl -X GET 10.44.99.102:9200/situation-event/_search?pretty -d 
 2 {
 3     "query": {
 4         "bool": {
 5             "must": [{
 6                 "term": {
 7                     "organization_id": "208"
 8                 }
 9             }],
10             "should": [{
11                     "terms": {
12                         "event_type": ["007", "008"]
13                     }
14                 }
15             ],
16             "minimum_should_match": 1
17         }
18     }
19 }
多條件查詢

 


免責聲明!

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



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