내용으로 건너뛰기
권남
사용자 도구
로그인
사이트 도구
검색
도구
문서 보기
이전 판
역링크
최근 바뀜
미디어 관리자
사이트맵
로그인
>
최근 바뀜
미디어 관리자
사이트맵
추적:
search: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 체크 ===== * [[https://www.elastic.co/guide/en/elasticsearch/guide/current/_dealing_with_null_values.html|Dealing with Null Values | Elasticsearch: The Definitive Guide [2.x] | Elastic]] * 값의 존재(''IS NOT NULL'') 체크<code json> GET /my_index/posts/_search { "query" : { "constant_score" : { "filter" : { "exists" : { "field" : "필드이름" } } } } } </code> * 값이 존재하지 않음(''IS NULL'') 체크(<code json> GET /my_index/posts/_search { "query" : { "constant_score" : { "filter": { "missing" : { "field" : "필드이름" } } } } } </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 ===== * [[https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html|Terms Aggregation]] * ''product'' 필드값으로 distinct 하고 결과를 5개까지 출력, 이때 검색결과는 출력하지 않고 통계 결과만출력 <code json> { "size": 0, // 검색결과 출력 안하게 "aggs" : { "products" : { "terms" : { "field" : "product", "size" : 5 } } } } </code> * 정렬하기<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, "aggs" : { "t_shirts" : { "filter" : { "term": { "type": "t-shirt" } }, "aggs" : { "avg_price" : { "avg" : { "field" : "price" } } } } } } </code>
search/elasticsearch/query.txt
· 마지막으로 수정됨: 2017/06/01 13:53 저자
kwon37xi
문서 도구
문서 보기
이전 판
역링크
맨 위로