'sort'에 해당되는 글 3건

  1. 2022.03.24 [Elasticsearch] Terms + Sub Sum Aggs 사례.
  2. 2018.02.13 [Script] uniq string line print on shell
  3. 2015.11.30 [Elasticsearch - The Definitive Guide] Sorting tips.

[Elasticsearch] Terms + Sub Sum Aggs 사례.

Elastic/Elasticsearch 2022. 3. 24. 18:13

문제)

하루 동안 데이터 요청을 가장 많이한 IP Top 5 를 구하시오.

 

해결)

GET /kibana_sample_data_logs/_search
{
  "size":0,
  "aggs": {
    "ip_aggs": {
      "terms": {
        "field": "ip"
      },
      "aggs": {
        "sum_aggs": {
          "sum": {
            "field": "bytes"
          }
        },
        "sum_aggs_sort": {
          "bucket_sort": {
            "sort": [
              { "sum_aggs": { "order": "desc" } } 
            ],
            "size": 5
          }
        }
      }
    }
  }
}

 

관련 문서)

https://www.elastic.co/guide/en/elasticsearch/reference/8.1/search-aggregations-bucket-terms-aggregation.html

https://www.elastic.co/guide/en/elasticsearch/reference/8.1/search-aggregations-pipeline-bucket-sort-aggregation.html

 

Elasticsearch 를 설치 하고 Kibana 를 이용해서 Sample Data 를 이용하였습니다.

그냥 Single node 로 구성 해서 테스트 해보실 수 있습니다.

:

[Script] uniq string line print on shell

ITWeb/개발일반 2018. 2. 13. 13:26

파일에 id 목록이 들어 있고 여기서 unique 한 id 들만 출력하고 싶을 경우 아래와 같이 사용 하시면 편하게 찾으 실 수 있습니다.


Tips)

$ sort id_list.log | uniq


Ref)

http://www.tutorialspoint.com/unix_commands/sort.htm

http://www.tutorialspoint.com/unix_commands/uniq.htm

:

[Elasticsearch - The Definitive Guide] Sorting tips.

Elastic/TheDefinitiveGuide 2015. 11. 30. 16:44

팁이라고 하기 좀 그렇지만 그냥 쉽게 놓칠수 있는 부분이 있어 기록 합니다.


[한 줄 요약]

- sorting 기능은 메모리를 많이 사용합니다.


[원문링크]


[원문 Snippet]

Sorting on a full-text analyzed field can use a lot of memory. See Fielddata for more information.

- FIelddata 는 보통 fielddata cache 기능을 이야기 합니다. 또한 circuit break 와 함께 참고 하셔야 합니다.


[팁]

- fields 사용 (전에는 multi fields 라고 불렀습니다.)

- analyzed field 에 대한 정렬은 메모리를 많이 사용하기 때문에 주의 해서 사용합니다.


: