사용자 도구

사이트 도구


search:elasticsearch:query

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판
이전 판
search:elasticsearch:query [2017/06/01 10:41]
kwon37xi
search:elasticsearch:query [2017/06/01 13:53] (현재)
kwon37xi
줄 1: 줄 1:
 ====== ElasticSearch Query ====== ====== ElasticSearch Query ======
 +
 +===== From/Limit =====
 +  * 쿼리 결과 ''from/limit'' 지정<code json>
 +GET /_search
 +{
 +    "from" : 0, "size" : 10,
 +    "query" : {
 +        "term" : { "user" : "kimchy" }
 +    }
 +}
 +// 혹은
 +GET /_search?from=0&size=10
 +</code>
  
 ===== null 체크 ===== ===== null 체크 =====
줄 27: 줄 40:
 } }
 </code> </code>
 +===== 범위 (Range) =====
 +  * [[https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-range-query.html|Range Query]]<code json>
 +GET _search
 +{
 +    "query": {
 +        "range" : {
 +            "age" : {
 +                "gte" : 10, // "gt"
 +                "lte" : 20, // "lt"
 +                "boost" : 2.0
 +            }
 +        }
 +    }
 +}
 +</code>
 +  * ''gte'' : Greater-than or equal to
 +  * ''gt'' : Greater-than
 +  * ''lte'' : Less-than or equal to
 +  * ''lt'' : Less-than
 +  * ''boost'' : Sets the boost value of the query, defaults to 1.0
  
 ===== Distinct Field ===== ===== Distinct Field =====
줄 43: 줄 76:
 } }
 </code> </code>
-  * ''terms'' 필터와 함께 적용[[https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filter-aggregation.html|Filter Aggregation]] <code json>+  * 정렬하기<code json> 
 +
 +    "aggs" : { 
 +        "genres" : { 
 +            "terms" : { 
 +                "field" : "genre", 
 +                "order" : { "_count" : "asc" }  // asc/desc 
 +            } 
 +        } 
 +    } 
 +
 +</code> 
 +    * ''_term'' : 키로 정렬 
 +    * ''_count'' : 키의 존재 갯수로 정렬 
 +  * 필터와 함께 적용[[https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filter-aggregation.html|Filter Aggregation]] <code json>
 { {
     "size": 0,     "size": 0,
search/elasticsearch/query.1496283109.txt.gz · 마지막으로 수정됨: 2017/06/01 10:41 저자 kwon37xi