Compound Query / Bool Query

compound 쿼리는 하나 이상의 쿼리를 조합하여 검색을 할수 있다. bool 쿼리 하위에 다른 쿼리들을 조합하여 복잡한 조건의 쿼리를 수행할 수 있다.

Bool Query

bool 쿼리는 주어진 다른 쿼리들과 논리 조합으로 검색을 할수 있다.

주요연산

POST _search
{
    "query": {
        "bool": {
            "must": {
                "term": {
                    "user": "kimchy"
                }
            },
            "filter": {
                "term": {
                    "tag": "tech"
                }
            },
            "must_not": {
                "range": {
                    "age": {
                        "gte": 10,
                        "lte": 20
                    }
                }
            },
            "should": [
                {
                    "term": {
                        "tag": "wow"
                    }
                },
                {
                    "term": {
                        "tag": "elasticsearch"
                    }
                }
            ],
            "minimum_should_match": 1,
            "boost": 1.0
        }
    }
}