문서의 이전 판입니다!
IS NOT NULL
) 체크GET /my_index/posts/_search { "query" : { "constant_score" : { "filter" : { "exists" : { "field" : "필드이름" } } } } }
IS NULL
) 체크(GET /my_index/posts/_search { "query" : { "constant_score" : { "filter": { "missing" : { "field" : "필드이름" } } } } }
product
필드값으로 distinct 하고 결과를 5개까지 출력, 이때 검색결과는 출력하지 않고 통계 결과만출력 { "size": 0, // 검색결과 출력 안하게 "aggs" : { "products" : { "terms" : { "field" : "product", "size" : 5 } } } }
terms
필터와 함께 적용Filter Aggregation { "size": 0, "aggs" : { "t_shirts" : { "filter" : { "term": { "type": "t-shirt" } }, "aggs" : { "avg_price" : { "avg" : { "field" : "price" } } } } } }