'Elastic'에 해당되는 글 498건

  1. 2016.11.24 [Elasticsearch] Lucene Arirang Analyzer Plugin for Elasticsearch 5.0.1
  2. 2016.11.21 [Kibana] Date Histogram Advanced DSL
  3. 2016.11.02 [Elasticsearch] Elasticsearch 5.0 GA 살펴보기 - 2
  4. 2016.11.02 [Elasticsearch] Elasticsearch 5.0 GA 살펴보기 - 1
  5. 2016.11.01 [Elasticsearch] Multi fields 질의
  6. 2016.10.18 [Range Query] datetime query 작성 예제.
  7. 2016.09.26 [스크랩] Elasticsearch nightly benchmarks
  8. 2016.08.16 [Logstash] Exception 에러로그 detection.
  9. 2016.08.10 [Elasticsearch] 2.3.x 에서 색인 성능 올려보기.
  10. 2016.07.22 [Elasticsearch] MoreLikeThis API 설명

[Elasticsearch] Lucene Arirang Analyzer Plugin for Elasticsearch 5.0.1

Elastic/Elasticsearch 2016. 11. 24. 19:02

우선 빌드한 플러그인 zip 파일 먼저 공유 합니다.

나중에 작업한 내용에 대해서는 github 에 올리도록 하겠습니다.

요즘 프로젝트며 운영 업무가 너무 많아서 이것도 겨우 겨우 시간 내서 작업 했내요.


elasticsearch-analysis-arirang-5.0.1.zip


설치 방법)

$ bin/elasticsearch-plugin install --verbose file:///elasticsearch-analysis-arirang/target/elasticsearch-analysis-arirang-5.0.1.zip


설치 로그)

-> Downloading file:///elasticsearch-analysis-arirang-5.0.1.zip

Retrieving zip from file:///elasticsearch-analysis-arirang-5.0.1.zip

[=================================================] 100%

- Plugin information:

Name: analysis-arirang

Description: Arirang plugin

Version: 5.0.1

 * Classname: org.elasticsearch.plugin.analysis.arirang.AnalysisArirangPlugin

-> Installed analysis-arirang


Elasticsearch 실행 로그)

$ bin/elasticsearch

[2016-11-24T18:49:09,922][INFO ][o.e.n.Node               ] [] initializing ...

[2016-11-24T18:49:10,083][INFO ][o.e.e.NodeEnvironment    ] [aDGu2B9] using [1] data paths, mounts [[/ (/dev/disk1)]], net usable_space [733.1gb], net total_space [930.3gb], spins? [unknown], types [hfs]

[2016-11-24T18:49:10,084][INFO ][o.e.e.NodeEnvironment    ] [aDGu2B9] heap size [1.9gb], compressed ordinary object pointers [true]

[2016-11-24T18:49:10,085][INFO ][o.e.n.Node               ] [aDGu2B9] node name [aDGu2B9] derived from node ID; set [node.name] to override

[2016-11-24T18:49:10,087][INFO ][o.e.n.Node               ] [aDGu2B9] version[5.0.1], pid[56878], build[080bb47/2016-11-11T22:08:49.812Z], OS[Mac OS X/10.12.1/x86_64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_72/25.72-b15]

[2016-11-24T18:49:11,335][INFO ][o.e.p.PluginsService     ] [aDGu2B9] loaded module [aggs-matrix-stats]

[2016-11-24T18:49:11,335][INFO ][o.e.p.PluginsService     ] [aDGu2B9] loaded module [ingest-common]

[2016-11-24T18:49:11,335][INFO ][o.e.p.PluginsService     ] [aDGu2B9] loaded module [lang-expression]

[2016-11-24T18:49:11,335][INFO ][o.e.p.PluginsService     ] [aDGu2B9] loaded module [lang-groovy]

[2016-11-24T18:49:11,335][INFO ][o.e.p.PluginsService     ] [aDGu2B9] loaded module [lang-mustache]

[2016-11-24T18:49:11,336][INFO ][o.e.p.PluginsService     ] [aDGu2B9] loaded module [lang-painless]

[2016-11-24T18:49:11,336][INFO ][o.e.p.PluginsService     ] [aDGu2B9] loaded module [percolator]

[2016-11-24T18:49:11,336][INFO ][o.e.p.PluginsService     ] [aDGu2B9] loaded module [reindex]

[2016-11-24T18:49:11,336][INFO ][o.e.p.PluginsService     ] [aDGu2B9] loaded module [transport-netty3]

[2016-11-24T18:49:11,336][INFO ][o.e.p.PluginsService     ] [aDGu2B9] loaded module [transport-netty4]

[2016-11-24T18:49:11,336][INFO ][o.e.p.PluginsService     ] [aDGu2B9] loaded plugin [analysis-arirang]

[2016-11-24T18:49:14,151][INFO ][o.e.n.Node               ] [aDGu2B9] initialized

[2016-11-24T18:49:14,151][INFO ][o.e.n.Node               ] [aDGu2B9] starting ...

[2016-11-24T18:49:14,377][INFO ][o.e.t.TransportService   ] [aDGu2B9] publish_address {127.0.0.1:9300}, bound_addresses {[fe80::1]:9300}, {[::1]:9300}, {127.0.0.1:9300}

[2016-11-24T18:49:17,511][INFO ][o.e.c.s.ClusterService   ] [aDGu2B9] new_master {aDGu2B9}{aDGu2B9mQ8KkWCe3fnqeMw}{_y9RzyKGSvqYAFcv99HBXg}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-elected-as-master ([0] nodes joined)

[2016-11-24T18:49:17,584][INFO ][o.e.g.GatewayService     ] [aDGu2B9] recovered [0] indices into cluster_state

[2016-11-24T18:49:17,588][INFO ][o.e.h.HttpServer         ] [aDGu2B9] publish_address {127.0.0.1:9200}, bound_addresses {[fe80::1]:9200}, {[::1]:9200}, {127.0.0.1:9200}

[2016-11-24T18:49:17,588][INFO ][o.e.n.Node               ] [aDGu2B9] started


한글형태소분석 실행)

$ curl -X POST -H "Cache-Control: no-cache" -H "Postman-Token: 6d392d83-5816-71ad-556b-5cd6f92af634" -d '{

  "analyzer" : "arirang_analyzer",

  "text" : "[한국] 엘라스틱서치 사용자 그룹의 HENRY 입니다."

}' "http://localhost:9200/_analyze"


형태소분석 결과)

{

  "tokens": [

    {

      "token": "[",

      "start_offset": 0,

      "end_offset": 1,

      "type": "symbol",

      "position": 0

    },

    {

      "token": "한국",

      "start_offset": 1,

      "end_offset": 3,

      "type": "korean",

      "position": 1

    },

    {

      "token": "]",

      "start_offset": 3,

      "end_offset": 4,

      "type": "symbol",

      "position": 2

    },

    {

      "token": "엘라스틱서치",

      "start_offset": 5,

      "end_offset": 11,

      "type": "korean",

      "position": 3

    },

    {

      "token": "엘라",

      "start_offset": 5,

      "end_offset": 7,

      "type": "korean",

      "position": 3

    },

    {

      "token": "스틱",

      "start_offset": 7,

      "end_offset": 9,

      "type": "korean",

      "position": 4

    },

    {

      "token": "서치",

      "start_offset": 9,

      "end_offset": 11,

      "type": "korean",

      "position": 5

    },

    {

      "token": "사용자",

      "start_offset": 12,

      "end_offset": 15,

      "type": "korean",

      "position": 6

    },

    {

      "token": "그룹",

      "start_offset": 16,

      "end_offset": 18,

      "type": "korean",

      "position": 7

    },

    {

      "token": "henry",

      "start_offset": 20,

      "end_offset": 25,

      "type": "word",

      "position": 8

    },

    {

      "token": "입니다",

      "start_offset": 26,

      "end_offset": 29,

      "type": "korean",

      "position": 9

    }

  ]

}


:

[Kibana] Date Histogram Advanced DSL

Elastic/Kibana 2016. 11. 21. 10:34

Kibana 를 사용하면서 많이 사용하는 것중 하나가 바로 Date Histogram Aggregation 입니다.

기본 결과에 대한 정렬은 count 에 대한 desc 으로 결과가 전달 되는데요.

날짜에 대한 desc 정렬을 하고 싶은 경우 아래와 같은 스크립트를 추가 하시면 됩니다.


제가 많이 사용하는 스크립트라 매번 타이핑 하기 귀찮아서 올려 봅니다.


{

"field":"time",

"interval":"1w",

  "order": {

    "_key": "desc"

  }

}


- field 값에 time 을 넣은 이유는 @timestamp 를 사용하기 않기 때문 입니다. :)

- order 에 사용 가능한 field 는 

Date Histogram 에서는 _key, _count

Terms 에서는 _term, _count

입니다.


:

[Elasticsearch] Elasticsearch 5.0 GA 살펴보기 - 2

Elastic/Elasticsearch 2016. 11. 2. 17:49

site plugin head 설치를 해보려 합니다.

설치 방법이 달라졌습니다.


[사전준비]

Elasticsearch 5.0 GA 살펴보기 - 1 에서 클러스터 구성

그냥 bin/elasticsearch, bin/elasticsearch 두 번 하시면 됩니다.


[설치 명령어]

https://www.elastic.co/guide/en/elasticsearch/plugins/current/installation.html#_core_elasticsearch_plugins


$ bin/elasticsearch-plugin install [plugin-name]


[Head Plugins]

https://github.com/mobz/elasticsearch-head#running-with-built-in-server


설치 방법은 위 문서에 잘 나와 있습니다.

아래는 제가 그냥 실행한 명령어를 나열 하였습니다.


$ git clone git://github.com/mobz/elasticsearch-head.git

$ cd elasticsearch-head/

$ npm install

$ sudo npm install -g grunt-cli

$ grunt server


[Head 접속]

$ open http://localhost:9100

- cross origin  정책으로 인해서 초기 접속이 되지 않습니다.

- elasticsearch.yml 에 아래 내용 추가해 주시고 재실행 하시면 됩니다.


[Cross Origin 정책수정]

$ vi config/elasticsearch.yml


http.cors.enabled: true

http.cors.allow-origin: "*"




노드명이 많이 아쉽내요 ㅠ.ㅠ

:

[Elasticsearch] Elasticsearch 5.0 GA 살펴보기 - 1

Elastic/Elasticsearch 2016. 11. 2. 17:11
내년에 업그레이드를 해야 하기 때문에 한번 살펴 보고자 합니다.

오늘은 가볍게 다운 받고 압축 풀고 기본 구조가 어떻게 변경이 되었나 한번 살펴 보려 합니다.


[다운로드]

https://www.elastic.co/downloads/elasticsearch


$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.0.0.tar.gz


[압축해제]

$ tar -xvzf elasticsearch-5.0.0.tar.gz

$ ln -s elasticsearch-5.0.0 elasticsearch


[바로실행]

$ bin/elasticsearch


[2016-11-02T16:52:22,051][INFO ][o.e.n.Node               ] [] initializing ...

[2016-11-02T16:52:22,246][INFO ][o.e.e.NodeEnvironment    ] [DiStpli] using [1] data paths, mounts [[/ (/dev/disk1)]], net usable_space [734.4gb], net total_space [930.3gb], spins? [unknown], types [hfs]

[2016-11-02T16:52:22,247][INFO ][o.e.e.NodeEnvironment    ] [DiStpli] heap size [1.9gb], compressed ordinary object pointers [true]

[2016-11-02T16:52:22,248][INFO ][o.e.n.Node               ] [DiStpli] node name [DiStpli] derived from node ID; set [node.name] to override

[2016-11-02T16:52:22,268][INFO ][o.e.n.Node               ] [DiStpli] version[5.0.0], pid[14095], build[253032b/2016-10-26T04:37:51.531Z], OS[Mac OS X/10.12.1/x86_64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_72/25.72-b15]

[2016-11-02T16:52:23,487][INFO ][o.e.p.PluginsService     ] [DiStpli] loaded module [aggs-matrix-stats]

[2016-11-02T16:52:23,487][INFO ][o.e.p.PluginsService     ] [DiStpli] loaded module [ingest-common]

[2016-11-02T16:52:23,488][INFO ][o.e.p.PluginsService     ] [DiStpli] loaded module [lang-expression]

[2016-11-02T16:52:23,488][INFO ][o.e.p.PluginsService     ] [DiStpli] loaded module [lang-groovy]

[2016-11-02T16:52:23,488][INFO ][o.e.p.PluginsService     ] [DiStpli] loaded module [lang-mustache]

[2016-11-02T16:52:23,488][INFO ][o.e.p.PluginsService     ] [DiStpli] loaded module [lang-painless]

[2016-11-02T16:52:23,488][INFO ][o.e.p.PluginsService     ] [DiStpli] loaded module [percolator]

[2016-11-02T16:52:23,488][INFO ][o.e.p.PluginsService     ] [DiStpli] loaded module [reindex]

[2016-11-02T16:52:23,488][INFO ][o.e.p.PluginsService     ] [DiStpli] loaded module [transport-netty3]

[2016-11-02T16:52:23,488][INFO ][o.e.p.PluginsService     ] [DiStpli] loaded module [transport-netty4]

[2016-11-02T16:52:23,489][INFO ][o.e.p.PluginsService     ] [DiStpli] no plugins loaded

[2016-11-02T16:52:27,399][INFO ][o.e.n.Node               ] [DiStpli] initialized

[2016-11-02T16:52:27,399][INFO ][o.e.n.Node               ] [DiStpli] starting ...

[2016-11-02T16:52:27,809][INFO ][o.e.t.TransportService   ] [DiStpli] publish_address {127.0.0.1:9300}, bound_addresses {[fe80::1]:9300}, {[::1]:9300}, {127.0.0.1:9300}

[2016-11-02T16:52:30,900][INFO ][o.e.c.s.ClusterService   ] [DiStpli] new_master {DiStpli}{DiStpli8S4-rE5QKCPP_Lw}{bwHQPV_UTl6NSPCfx8IE3w}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-elected-as-master ([0] nodes joined)

[2016-11-02T16:52:30,974][INFO ][o.e.h.HttpServer         ] [DiStpli] publish_address {127.0.0.1:9200}, bound_addresses {[fe80::1]:9200}, {[::1]:9200}, {127.0.0.1:9200}

[2016-11-02T16:52:30,974][INFO ][o.e.n.Node               ] [DiStpli] started

[2016-11-02T16:52:30,975][INFO ][o.e.g.GatewayService     ] [DiStpli] recovered [0] indices into cluster_state


[접속]

http://localhost:9200


{
  "name" : "DiStpli",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "eA4iUJ4BSoOxmoDbLjFgoQ",
  "version" : {
    "number" : "5.0.0",
    "build_hash" : "253032b",
    "build_date" : "2016-10-26T04:37:51.531Z",
    "build_snapshot" : false,
    "lucene_version" : "6.2.0"
  },
  "tagline" : "You Know, for Search"
}



[디렉토리구조]

$ ls -al

total 56

drwxr-xr-x  12  staff    408 11  2 16:52 .

drwxr-xr-x  34  staff   1156 11  2 16:45 ..

-rw-r--r--   1  staff  11358 10 26 13:35 LICENSE.txt

-rw-r--r--   1  staff    150 10 26 13:35 NOTICE.txt

-rw-r--r--   1  staff   9108 10 26 13:35 README.textile

drwxr-xr-x  15  staff    510 10 26 13:40 bin

drwxr-xr-x   6  staff    204 11  2 16:52 config

drwxr-xr-x   3  staff    102 11  2 16:52 data

drwxr-xr-x  36  staff   1224 10 26 13:40 lib

drwxr-xr-x   6  staff    204 11  2 16:52 logs

drwxr-xr-x  12  staff    408 10 26 13:40 modules

drwxr-xr-x   2  staff     68 11  2 16:52 plugins


- 실행 후 모습 입니다.


[디렉토리 bin]

- 실행 파일들이 위치해 있습니다.


[디렉토리 config]

- elasticsearch.yml 은 그대로 존재 합니다.

- logging.yml 은 log4j2.properties 로 변경 되었습니다.

- jvm.options 가 추가 되었습니다.

기존에 실행 시 설정에 필요했던 jvm 옵션을 스크립트에 추가 하기 위해 커스텀하게 사용했는데요. 이 옵션이 생겨서 좀 더 유연해 졌내요.

- scripts 디렉토리가 생겼습니다.

잘 아시겠지만 각종 script 관련 코드를 이곳에 저장하고 읽어 들일 수 있도록 된 것 같습니다.


[디렉토리 data]

- 예전 그대로 같지만 조금 달라졌습니다.

즉, 예전에는 data/클러스터명/nodes/0 뭐 이런 식이였는데요.

지금은 data/nodes/0 으로 생성이 되내요.

클러스터명이 사라졌내요. (여전히 default cluster_name 은 elasticsearch 입니다.)


[디렉토리 lib]

- 바뀐건 종속 라이브러리가 바뀌었내요.


[디렉토리 modules]

- elastic 에서 제공하는 추가 modules 들이 들어 있습니다.


[디렉토리 plugins]

- 바뀐건 아마도 plugin 만드는 방법이 바뀌었을 것 같습니다.


[초간단 클러스터 구성 테스트]

- 기본적으로 elasticsearch 는 bin/elasticsearch 를 여러번 실행 하면 클러스터로 묶어 줍니다.

단, 인스턴스를 분리 하셔야 합니다.


$ bin/elasticsearch

[2016-11-02T17:21:04,689][INFO ][o.e.n.Node               ] [] initializing ...

[2016-11-02T17:21:04,770][INFO ][o.e.e.NodeEnvironment    ] [npjHq7P] using [1] data paths, mounts [[/ (/dev/disk1)]], net usable_space [734.4gb], net total_space [930.3gb], spins? [unknown], types [hfs]

[2016-11-02T17:21:04,771][INFO ][o.e.e.NodeEnvironment    ] [npjHq7P] heap size [1.9gb], compressed ordinary object pointers [true]

[2016-11-02T17:21:04,772][INFO ][o.e.n.Node               ] [npjHq7P] node name [npjHq7P] derived from node ID; set [node.name] to override

[2016-11-02T17:21:04,773][INFO ][o.e.n.Node               ] [npjHq7P] version[5.0.0], pid[14680], build[253032b/2016-10-26T04:37:51.531Z], OS[Mac OS X/10.12.1/x86_64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_72/25.72-b15]

[2016-11-02T17:21:05,375][INFO ][o.e.p.PluginsService     ] [npjHq7P] loaded module [aggs-matrix-stats]

[2016-11-02T17:21:05,375][INFO ][o.e.p.PluginsService     ] [npjHq7P] loaded module [ingest-common]

[2016-11-02T17:21:05,376][INFO ][o.e.p.PluginsService     ] [npjHq7P] loaded module [lang-expression]

[2016-11-02T17:21:05,376][INFO ][o.e.p.PluginsService     ] [npjHq7P] loaded module [lang-groovy]

[2016-11-02T17:21:05,376][INFO ][o.e.p.PluginsService     ] [npjHq7P] loaded module [lang-mustache]

[2016-11-02T17:21:05,376][INFO ][o.e.p.PluginsService     ] [npjHq7P] loaded module [lang-painless]

[2016-11-02T17:21:05,376][INFO ][o.e.p.PluginsService     ] [npjHq7P] loaded module [percolator]

[2016-11-02T17:21:05,376][INFO ][o.e.p.PluginsService     ] [npjHq7P] loaded module [reindex]

[2016-11-02T17:21:05,376][INFO ][o.e.p.PluginsService     ] [npjHq7P] loaded module [transport-netty3]

[2016-11-02T17:21:05,376][INFO ][o.e.p.PluginsService     ] [npjHq7P] loaded module [transport-netty4]

[2016-11-02T17:21:05,377][INFO ][o.e.p.PluginsService     ] [npjHq7P] no plugins loaded

[2016-11-02T17:21:06,764][INFO ][o.e.n.Node               ] [npjHq7P] initialized

[2016-11-02T17:21:06,765][INFO ][o.e.n.Node               ] [npjHq7P] starting ...

[2016-11-02T17:21:06,895][INFO ][o.e.t.TransportService   ] [npjHq7P] publish_address {127.0.0.1:9301}, bound_addresses {[fe80::1]:9301}, {[::1]:9301}, {127.0.0.1:9301}

[2016-11-02T17:21:09,996][INFO ][o.e.c.s.ClusterService   ] [npjHq7P] detected_master {DiStpli}{DiStpli8S4-rE5QKCPP_Lw}{oJ9y-SxJTYex3ZNBmRIpoQ}{127.0.0.1}{127.0.0.1:9300}, added {{DiStpli}{DiStpli8S4-rE5QKCPP_Lw}{oJ9y-SxJTYex3ZNBmRIpoQ}{127.0.0.1}{127.0.0.1:9300},}, reason: zen-disco-receive(from master [master {DiStpli}{DiStpli8S4-rE5QKCPP_Lw}{oJ9y-SxJTYex3ZNBmRIpoQ}{127.0.0.1}{127.0.0.1:9300} committed version [7]])

[2016-11-02T17:21:10,030][INFO ][o.e.h.HttpServer         ] [npjHq7P] publish_address {127.0.0.1:9201}, bound_addresses {[fe80::1]:9201}, {[::1]:9201}, {127.0.0.1:9201}

[2016-11-02T17:21:10,031][INFO ][o.e.n.Node               ] [npjHq7P] started



$ bin/elasticsearch

[2016-11-02T17:19:34,869][INFO ][o.e.n.Node               ] [] initializing ...

[2016-11-02T17:19:35,074][INFO ][o.e.e.NodeEnvironment    ] [DiStpli] using [1] data paths, mounts [[/ (/dev/disk1)]], net usable_space [734.4gb], net total_space [930.3gb], spins? [unknown], types [hfs]

[2016-11-02T17:19:35,074][INFO ][o.e.e.NodeEnvironment    ] [DiStpli] heap size [1.9gb], compressed ordinary object pointers [true]

[2016-11-02T17:19:35,076][INFO ][o.e.n.Node               ] [DiStpli] node name [DiStpli] derived from node ID; set [node.name] to override

[2016-11-02T17:19:35,079][INFO ][o.e.n.Node               ] [DiStpli] version[5.0.0], pid[14588], build[253032b/2016-10-26T04:37:51.531Z], OS[Mac OS X/10.12.1/x86_64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_72/25.72-b15]

[2016-11-02T17:19:37,110][INFO ][o.e.p.PluginsService     ] [DiStpli] loaded module [aggs-matrix-stats]

[2016-11-02T17:19:37,111][INFO ][o.e.p.PluginsService     ] [DiStpli] loaded module [ingest-common]

[2016-11-02T17:19:37,111][INFO ][o.e.p.PluginsService     ] [DiStpli] loaded module [lang-expression]

[2016-11-02T17:19:37,111][INFO ][o.e.p.PluginsService     ] [DiStpli] loaded module [lang-groovy]

[2016-11-02T17:19:37,111][INFO ][o.e.p.PluginsService     ] [DiStpli] loaded module [lang-mustache]

[2016-11-02T17:19:37,111][INFO ][o.e.p.PluginsService     ] [DiStpli] loaded module [lang-painless]

[2016-11-02T17:19:37,111][INFO ][o.e.p.PluginsService     ] [DiStpli] loaded module [percolator]

[2016-11-02T17:19:37,111][INFO ][o.e.p.PluginsService     ] [DiStpli] loaded module [reindex]

[2016-11-02T17:19:37,111][INFO ][o.e.p.PluginsService     ] [DiStpli] loaded module [transport-netty3]

[2016-11-02T17:19:37,111][INFO ][o.e.p.PluginsService     ] [DiStpli] loaded module [transport-netty4]

[2016-11-02T17:19:37,111][INFO ][o.e.p.PluginsService     ] [DiStpli] no plugins loaded

[2016-11-02T17:19:40,144][INFO ][o.e.n.Node               ] [DiStpli] initialized

[2016-11-02T17:19:40,145][INFO ][o.e.n.Node               ] [DiStpli] starting ...

[2016-11-02T17:19:40,356][INFO ][o.e.t.TransportService   ] [DiStpli] publish_address {127.0.0.1:9300}, bound_addresses {[fe80::1]:9300}, {[::1]:9300}, {127.0.0.1:9300}



[2016-11-02T17:19:43,625][INFO ][o.e.c.s.ClusterService   ] [DiStpli] new_master {DiStpli}{DiStpli8S4-rE5QKCPP_Lw}{oJ9y-SxJTYex3ZNBmRIpoQ}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-elected-as-master ([0] nodes joined)

[2016-11-02T17:19:43,742][INFO ][o.e.g.GatewayService     ] [DiStpli] recovered [0] indices into cluster_state

[2016-11-02T17:19:43,750][INFO ][o.e.h.HttpServer         ] [DiStpli] publish_address {127.0.0.1:9200}, bound_addresses {[fe80::1]:9200}, {[::1]:9200}, {127.0.0.1:9200}

[2016-11-02T17:19:43,750][INFO ][o.e.n.Node               ] [DiStpli] started

[2016-11-02T17:21:09,966][INFO ][o.e.c.s.ClusterService   ] [DiStpli] added {{npjHq7P}{npjHq7PlTqqiB2bhXkIxqQ}{IhQPGv_rTsyd7a1DbXFMwA}{127.0.0.1}{127.0.0.1:9301},}, reason: zen-disco-node-join[{npjHq7P}{npjHq7PlTqqiB2bhXkIxqQ}{IhQPGv_rTsyd7a1DbXFMwA}{127.0.0.1}{127.0.0.1:9301}]

[2016-11-02T17:21:10,007][WARN ][o.e.d.z.ElectMasterService] [DiStpli] value for setting "discovery.zen.minimum_master_nodes" is too low. This can result in data loss! Please set it to at least a quorum of master-eligible nodes (current value: [-1], total number of master-eligible nodes used for publishing in this round: [2])

- 친절하게 quorum 구성 하라고 메시지도 보여 주내요.

:

[Elasticsearch] Multi fields 질의

Elastic/Elasticsearch 2016. 11. 1. 13:33

요즘 추천 데이터 만드느라 도통 mapping 정보 설계나 dsl 작성을 안했더니 까먹기 일수내요.

그래서 그냥 기억하는 차원에서 가볍게 작성해 봅니다.


[참고문서]

https://www.elastic.co/guide/en/elasticsearch/reference/2.4/multi-fields.html


[설명]

- 예전에는 multi-field 라고 했고 지금은 fields 라고 합니다.

- fields 의 용도는 단일 field 에 여러가지 속성을 부여하고 싶을 때 사용을 합니다.


예를 들면)

- index:analyzed 로 선언을 했는데 정렬을 해야 할 경우.

- index:not_analyzed 로 선언을 했는데 같은 value로 fulltext 검색을 해야 할 경우.


보통은 index:analyzed 로 선언 하고 fields 로 index:not_analyzed 로 구성 하는게 많습니다.


[mappings 정보]

...중략...

"keyword": { "type":"string", "index":"analyzed", "analyzer":"edge_ngram_analyzer", "index_options":"docs", "norms": { "enabled":false },

  "fields": {

    "exact": {

      "type":"string", "index":"not_analyzed", "store":"no"

    }

  }

},

...중략...

- 위 맵핑 정보는 제가 자동완성에서 사용하는 정보를 일부 발췌한 내용입니다.


[query dsl]

{

  "query": {

    "term": {

      "keyword.exact": "향수"

    }

  }

}

- 질의는 위에서와 같이 .(dot) 을 이용해서 field 명을 사용하시면 됩니다.

:

[Range Query] datetime query 작성 예제.

Elastic/Elasticsearch 2016. 10. 18. 11:15

늘 그렇듯이 기억력의 한계 극복을 위해 기록합니다.


              "range": {
                "time": {
                  "gte": "2016-10-17 00:00:00.000",
                  "lte": "2016-10-17 23:59:59.999",
                  "format": "yyyy-MM-dd HH:mm:ss.SSS",
                  "time_zone": "+09:00"
                }
              }


보시면 다들 아시는 내용입니다.


[참고문서]

https://www.elastic.co/guide/en/elasticsearch/reference/2.4/query-dsl-range-query.html

https://www.elastic.co/guide/en/elasticsearch/reference/2.4/mapping-date-format.html

https://www.elastic.co/guide/en/elasticsearch/reference/2.4/date.html

:

[스크랩] Elasticsearch nightly benchmarks

Elastic/Elasticsearch 2016. 9. 26. 16:27

일단 Keep!


https://elasticsearch-benchmarks.elastic.co/index.html

:

[Logstash] Exception 에러로그 detection.

Elastic/Logstash 2016. 8. 16. 12:35

바빠서 초간단 버전 업데이트 합니다.


1. patterns 생성)

잘 아시겠지만 grok filter 에서의 pattern 은 deprecated 되었습니다. 그래서 patterns_dir 을 만들어서 설정을 하셔야 합니다.

저는 그냥 기존에 생성된 LOGLEVEL 패턴에 (Ee)xception 만 추가 했습니다.


patterns/patterns

LOGLEVEL ([Ee]xception|EXCEPTION|[Aa]lert|ALERT|[Tt]race|TRACE|[Dd]ebug|DEBUG|[Nn]otice|NOTICE|[Ii]nfo|INFO|[Ww]arn?(?:ing)?|WARN?(?:ING)?|[Ee]rr?(?:or)?|ERR?(?:OR)?|[Cc]rit?(?:ical)?|CRIT?(?:ICAL)?|[Ff]atal|FATAL|[Ss]evere|SEVERE|EMERG(?:ENCY)?|[Ee]merg(?:ency)?)


[참고]

https://github.com/logstash-plugins/logstash-patterns-core/blob/master/patterns/grok-patterns


2. config 생성)

input {

  file {

    path => "/server/elastic/elasticsearch-2.3.5/logs/*.log"

  }

}


filter {

  grok {

    patterns_dir => ["./patterns"]

    match => {

      "message" => "%{LOGLEVEL:error_log}"

    }

  }


  if "_grokparsefailure" in [tags] {

    drop { }

  }

}


output {

  if [error_log] in ["Exception","exception"] {

    stdout {

      codec => "rubydebug"

    }

  }

}


이 설정의 용도는 elasticsearch 에서 발생하는 exception 을 감지 하기 위한 것입니다.

초간단 버전이니 튜닝은 각자 잘 하시면 됩니다.



※ 실제 이것만 가지고 서비스에 적용하시면 문제 발생 할 수 있습니다.

filebeats 와 연동해서 사용하시길 권장 드립니다.

:

[Elasticsearch] 2.3.x 에서 색인 성능 올려보기.

Elastic/Elasticsearch 2016. 8. 10. 16:42

trade-off 가 있긴 하지만 그럼에도 불구하고 색인 성능을 확보 하고 싶으신 분들은 한번 고려해 보셔도 될 것 같습니다.


기본 설정은 sync 입니다.


index.translog.durability: async


추가적으로 software 적인 raid 구조를 사용하고 계시다면, disk i/o 성능이 떨어 지게 되기 때문에 사용하지 않는 걸 추천 드립니다.

:

[Elasticsearch] MoreLikeThis API 설명

Elastic/Elasticsearch 2016. 7. 22. 16:21

mlt 를 이용하면 쉽게 추천 기능을 구현 할 수 있습니다.

그래서 해당 API에 대한 문서를 제 맘데로 옮겨다 놓았습니다.

추후 elasticsearch + mlt 를 이용한 machine learning 이나 recommendation 구현 방법에 대해서 공유 하도록 하겠습니다.


참고문서)

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-mlt-query.html


API 설명)

More Like This Query

- MLT 쿼리는 주어진 문서셋과 같은 문서를 찾도록 해줍니다.

- 입력된 문서의 대표 키워드 셋을 가지고 질의 하여 결과를 리턴하게 됩니다.

- 리턴된 결과의 문서들은 대표 키워드 셋과 유사한 문서들로 구성 되게 됩니다.

- MLT 질의 시 문서 또는 키워드로 질의를 할 수 있습니다.


Parameters


Document Input Parameters

  - like

    작성된 문서 또는 text를 바탕으로 문서를 검색 합니다.

  - unlike

    작성된 문서 또는 text에서 제외 시킬 term을 작성 합니다.

  - fields

    문서에서 analyzed text 를 가져올 필드를 지정 합니다.

    이 필드를 대상으로 질의 수행이 이루어 집니다.

  - like_text

    like 와 더불어 문서를 검색 할떄 추가적으로 사용할 text를 작성 합니다.

  - ids or docs

    @deprecated


Term Selection Parameters

  - max_query_terms

    작성된 문서 또는 text에서 추출하여 사용할 최대 query term size 입니다. (default 25)

  - min_term_freq

    작성된 문서 또는 text의 최소 TF 값으로 이 값보다 작을 경우 작성된 문서와 text는 무시 됩니다. (default 2)

  - min_doc_freq

    입력된 개별 term들에 대해서 각각 matching 된 문서의 최소 크기로 해당 크기 보다 작은 term의 결과는 무시 됩니다. (default 5)

  - max_doc_freq

    입력된 개별 term들에 대해서 각각 matching 된 문서의 최대 크기로 해당 크기 보다 큰 term의 결과는 무시 됩니다. (default unbounded 0)

  - min_word_length

    입력된 개별 term들의 최소 길이로 정의한 값보다 작은 term은 무시 됩니다. (default 0)

  - max_word_length

    입력된 개별 term들의 최대 길이로 정의한 값보다 큰 term은 무시 됩니다. (default unbounded 0)

  - stop_words

    불용어 목록을 등록 합니다.

  - analyzer

    입력한 문서와 text에 대한 analyzer 를 지정 합니다. 지정 하지 않을 경우 first field 의 analyzer 를 사용하게 됩니다.


Query Formation Parameters

  - minimum_should_match

    작성된 문서 또는 text에서 추출된 term matching 에 대한 minimum_should_match 정보를 구성 합니다. (default 30%)

  - boost_terms

    tems boost value 를 지정 합니다.

  - include

    검색 결과로 입력 문서를 포함 할지 말지를 결정 합니다. (default false)

  - boost

    전체 질의에 대한 boost value 를 지정 합니다. (default 1.0)


샘플 QueryDSL)

{

  "query": {

    "more_like_this": {

      "fields": [

        "title"

      ],

      "like": "마스크 수분",

      "min_term_freq": 1,

      "min_doc_freq": 10,

      "min_word_length": 2,

      "include": true

    }

  },

  "from": 0,

  "size": 5,

  "fields": [

    "id",

    "title"

  ]

}


: