ES 並且或者查詢


must should 的使用
GET /http_index/type/_search
{
  "query": {
    "bool": {
      "should": [
        {
          "bool": {
            "must": [
              {
                 "term" : {
                  "field1" : {
                    "value" : 110,
                    "boost" : 1.0
                  }
                }
              },
                {
                  
                  "terms": {"field2": [
                  100037,
                  100055,
                  100060
                  ]
                }
                }
            ]
          }
        },
        {
          "bool": {
            "must": [
                {"terms": {"field3": ["1001001"]}}
            ]
          }
        }
      ]
    }
  }
}

 

{
    "query": {
        "bool": {
            "must": {
                //or條件組裝
                "bool" : { 
                    "should": [
                        { "match": { "about": "music" }},
                        { "match": { "about": "climb" }} ] 
                }
            },
            "must": {
                "match": { "first_nale": "John" }
            },
            "must_not": {
                "match": {"last_name": "Smith" }
            }
        }
}

 


免責聲明!

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



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