복합Query

ElasticSearch 2018. 4. 6. 09:44

엘라스틱을 사용하다 보면 여러가지의 Query를 복합해서 사용해야 하는 경우가 있다.


잘 섞이는 Query는

  must, must_not, should  + (filter)이며 아래와 같이 "bool"로 연결한다.   REF


{
    "bool": {
        "must":     { "match": { "title": "how to make millions" }},
        "must_not": { "match": { "tag":   "spam" }},
        "should": [
            { "match": { "tag": "starred" }}
        ],
        "filter": {
          "range": { "date": { "gte": "2014-01-01" }} 
        }
    }
}


Posted by yongary
,