from/limit 지정GET /_search
{
"from" : 0, "size" : 10,
"query" : {
"term" : { "user" : "kimchy" }
}
}
// 혹은
GET /_search?from=0&size=10
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" : "필드이름" }
}
}
}
}
GET _search
{
"query": {
"range" : {
"age" : {
"gte" : 10, // "gt"
"lte" : 20, // "lt"
"boost" : 2.0
}
}
}
}
gte : Greater-than or equal togt : Greater-thanlte : Less-than or equal tolt : Less-thanboost : Sets the boost value of the query, defaults to 1.0product 필드값으로 distinct 하고 결과를 5개까지 출력, 이때 검색결과는 출력하지 않고 통계 결과만출력 {
"size": 0, // 검색결과 출력 안하게
"aggs" : {
"products" : {
"terms" : {
"field" : "product",
"size" : 5
}
}
}
}
{
"aggs" : {
"genres" : {
"terms" : {
"field" : "genre",
"order" : { "_count" : "asc" } // asc/desc
}
}
}
}
_term : 키로 정렬_count : 키의 존재 갯수로 정렬{
"size": 0,
"aggs" : {
"t_shirts" : {
"filter" : { "term": { "type": "t-shirt" } },
"aggs" : {
"avg_price" : { "avg" : { "field" : "price" } }
}
}
}
}