|
Elastic/Elasticsearch 2014. 2. 14. 18:18
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-boost-field.html#mapping-boost-field
_boost 도 1.0.0 에서는 삭제 되었내요. 대신 문서에 나와 있는 것 처럼 function_score 를 이용해서 사용하라는데 뭐 이건 그냥 query boosting script 내요.. ㅋ
Elastic/Elasticsearch 2014. 2. 14. 17:27
elasticsearch 1.0.0 에서 이전에 사용하던 API 의 return 값과 다른 것들이 좀 보입니다.
사용하시면서 기존 구조만 믿고 그냥 쓰시면 큰 낭패를 보실 수도 있을 듯 하내요. 아마도 _cat (http://www.elasticsearch.org/blog/introducing-cat-api/) 기능이 들어 가면서 영향을 받은 것들이 좀 되구요. settings, add document, get document 등도 조금씩 달라진게 있습니다. 그냥 참고들 하세요.
대표적으로 많이 바뀐 API 하나 맛보기로 보여 드립니다. 아래는 제가 쓰고 있는 책의 예제로 클러스터 구성하던걸 띄워 본거라.. 좀 길게 나오내요.. 그래서 중복된 것들은 삭제 했습니다.. ^^;
$ curl -XGET 'http://localhost:9200/_nodes?pretty=true' { "cluster_name" : "cluster_node", "nodes" : { "-Rr1fhFpTy2tYjQk9qWSQw" : { "name" : "node2", "transport_address" : "inet[/127.0.0.1:9301]", "host" : "jeong-ui-MacBook-Pro.local", "ip" : "192.168.0.117", "version" : "1.0.0", "build" : "a46900e", "http_address" : "inet[localhost/127.0.0.1:9201]", "attributes" : { "master" : "true" }, "settings" : { "index" : { "mapper" : { "dynamic" : "true" }, "number_of_replicas" : "0", "number_of_shards" : "5", "refresh_interval" : "1s" }, "gateway" : { "type" : "local" }, "pidfile" : "es.pid", "network" : { "host" : "localhost" }, "node" : { "data" : "true", "master" : "true", "name" : "node2" }, "http" : { "port" : "9201", "enabled" : "true" }, "transport" : { "tcp" : { "compress" : "true", "port" : "9301" } }, "name" : "node2", "action" : { "disable_shutdown" : "true", "auto_create_index" : "true" }, "path" : { "logs" : "/Users/hwjeong/server/app/elasticsearch/node2/logs", "home" : "/Users/hwjeong/server/app/elasticsearch/node2" }, "cluster" : { "name" : "cluster_node" }, "discovery" : { "zen" : { "minimum_master_nodes" : "2", "ping" : { "unicast" : { "hosts" : [ "localhost:9300", "localhost:9301", "localhost:9302" ] }, "multicast" : { "enabled" : "false" } } } }, "foreground" : "yes" }, "os" : { "refresh_interval" : 1000, "available_processors" : 8, "cpu" : { "vendor" : "Intel", "model" : "MacBookPro10,1", "mhz" : 2400, "total_cores" : 8, "total_sockets" : 8, "cores_per_socket" : 16, "cache_size_in_bytes" : 256 }, "mem" : { "total_in_bytes" : 8589934592 }, "swap" : { "total_in_bytes" : 5368709120 } }, "process" : { "refresh_interval" : 1000, "id" : 2447, "max_file_descriptors" : 10240, "mlockall" : false }, "jvm" : { "pid" : 2447, "version" : "1.6.0_65", "vm_name" : "Java HotSpot(TM) 64-Bit Server VM", "vm_version" : "20.65-b04-462", "vm_vendor" : "Apple Inc.", "start_time" : 1392355185303, "mem" : { "heap_init_in_bytes" : 268435456, "heap_max_in_bytes" : 1060372480, "non_heap_init_in_bytes" : 24317952, "non_heap_max_in_bytes" : 136314880, "direct_max_in_bytes" : 1060372480 }, "gc_collectors" : [ "ParNew", "ConcurrentMarkSweep" ], "memory_pools" : [ "Code Cache", "Par Eden Space", "Par Survivor Space", "CMS Old Gen", "CMS Perm Gen" ] }, "thread_pool" : { "generic" : { "type" : "cached", "keep_alive" : "30s" }, "index" : { "type" : "fixed", "min" : 8, "max" : 8, "queue_size" : "200" }, "get" : { "type" : "fixed", "min" : 8, "max" : 8, "queue_size" : "1k" }, "snapshot" : { "type" : "scaling", "min" : 1, "max" : 4, "keep_alive" : "5m" }, "merge" : { "type" : "scaling", "min" : 1, "max" : 4, "keep_alive" : "5m" }, "suggest" : { "type" : "fixed", "min" : 8, "max" : 8, "queue_size" : "1k" }, "bulk" : { "type" : "fixed", "min" : 8, "max" : 8, "queue_size" : "50" }, "optimize" : { "type" : "fixed", "min" : 1, "max" : 1 }, "warmer" : { "type" : "scaling", "min" : 1, "max" : 4, "keep_alive" : "5m" }, "flush" : { "type" : "scaling", "min" : 1, "max" : 4, "keep_alive" : "5m" }, "search" : { "type" : "fixed", "min" : 24, "max" : 24, "queue_size" : "1k" }, "percolate" : { "type" : "fixed", "min" : 8, "max" : 8, "queue_size" : "1k" }, "management" : { "type" : "scaling", "min" : 1, "max" : 5, "keep_alive" : "5m" }, "refresh" : { "type" : "scaling", "min" : 1, "max" : 4, "keep_alive" : "5m" } }, "network" : { "refresh_interval" : 5000, "primary_interface" : { "address" : "192.168.0.117", "name" : "en0", "mac_address" : "28:CF:E9:14:C5:C9" } }, "transport" : { "bound_address" : "inet[/127.0.0.1:9301]", "publish_address" : "inet[/127.0.0.1:9301]" }, "http" : { "bound_address" : "inet[/127.0.0.1:9201]", "publish_address" : "inet[/127.0.0.1:9201]", "max_content_length_in_bytes" : 104857600 }, "plugins" : [ ] }, .................. 요기 부터 클러스터 노드 정보들로 중복 입니다. } } }
Elastic/Elasticsearch 2014. 2. 13. 16:58
es 1.0.0 올리면서 사라진 API 입니다. FieldQueryBuilder 가 없어졌내요. beta2 까지 있었는데 RC1 부터 없어졌내요. 일단 fieldquerybuilder 는 기존에 querystringquerybuilder 랑 동일하다고 보시면 됩니다. 그렇기 때문에 중복되는 api 를 남겨둘 필요가 없었던게 아닌가 싶내요. ^^
그리고 추가적으로 하나 더...
기존에 bin/elasticsearch 하면 backgroud 로 실행이 되었는데 이제는 그냥 foreground 로 실행이 되내요.. background 로 실행 하고 싶으실 경우 아래와 같이 실행 하시면 됩니다.
bin/elasticsearch -Des.pidfile=es.pid > /dev/null 2>&1 &
Elastic/Elasticsearch 2014. 2. 13. 10:48
http://www.elasticsearch.org/blog/1-0-0-released/ ㅎㅎ 드뎌 릴리즈 되었내요. 아래는 블로그에 올라와 있는 key features 입니다.
The main features available in 1.0 are: -
Snapshot/Restore API
Backup or restore select indices or the whole cluster to a shared filesystem, S3 or HDFS via a simple API.
Blog: Introducing snapshot & restore, Docs: Snapshot/Restore
-
Aggregations
Aggregations are “facets” reborn, providing more powerful, more
flexible real-time analytics. Aggregations can be combined with each
other and nested, to slice and dice your data exactly the way you want
it. Includes the new geohash grid aggregation for geo-clustering.
Blog: Data visualization with elasticsearch aggregations and D3, Docs: Aggregations
-
Distributed Percolation
Percolation is search reversed: instead of running a query to find
matching docs, we can percolate a document to find matching queries.
While percolation was already available before, this release makes
percolation distributed, so that it will scale with your cluster.
Percolation now supports highlighted search snippets, aggregations and
bulk percolation.
Blog: Redesigned percolator, Docs: Percolator
-
cat API
Easy to read, console-based insight into what is happening in your
cluster. Particularly useful to the sysadmin when the alarm goes off at
3am and JSON is too difficult to read.
Blog: Introducing the cat API, Docs: cat API
-
Federated search
The tribe node joins multiple clusters and acts as a federated
client. Almost all operations are supported: distributed search,
suggestions, percolation. You can even index into multiple clusters with
the tribe node. Alternatively, you can set a tribe node to not allow
any write operations, making it read-only.
Docs: Tribe node
-
Doc values
Some of those beautiful aggregations can use a lot of memory,
especially when they involve text fields. Doc values store field values
on disk rather than in memory, allowing you to run aggregations on much
bigger datasets, at the cost of a little performance.
Blog: disk-based field data a.k.a. doc values, Docs: Doc Values
-
Circuit breaker
There are a few sharp edges in Elasticsearch, places where you can
hurt yourself if you are not careful. We are working on adding “circuit
breaker” functionality to prevent you from doing so. The first circuit
breaker detects attempts to load too much fielddata into memory, which
may cause OOM (out of memory) exceptions. More circuit breakers will
follow.
Docs: Fielddata circuit breaker
0.90.11 에서 1.0.0 으로 버전 올렸는데 일단 문제 없이 마이그레이션은 바로 되내요. 일단 기본 검색 기능들도 잘 동작 하구요. API 변경은 소스코드나 github 에 change log 를 봐야겠내요. 일단 기존에 구현하던 프로젝트에 1.0.0 적용한 바로는 ㅎㅎ 문제 없내요.
굿굿굿....
Elastic/Elasticsearch 2014. 2. 12. 18:12
http://www.elasticsearch.org/blog/data-visualization-elasticsearch-aggregations/ 데이터 분석에 치중하는 모습이 최근들어 많이 보입니다. 그렇다 보니 당연히 facet 기능 향상이 빠르게 되고 있내요. 여기에 d3 를 이용해서 data visualization 까지 지원 하고 있내요.
Elastic/Elasticsearch 2014. 2. 7. 10:18
http://www.elasticsearch.org/blog/elasticsearch-hadoop-1-3-m2/
몇 가지 기능 개선이랑 패키지명이 바뀌었내요. 그리고 기존에는 es.host 로 node 하나만 지정 할 수 있었는데 es.nodes 로 바뀐거 보면 병렬 분산 처리를 지원 하는 것 처럼 보이내요.
Elastic/Elasticsearch 2014. 1. 28. 16:47
elasticsearch 에서 어떤식으로 index 와 document 를 분산 시키는지 궁금 하신 분들이 계실걸로 압니다. 뭐 소스 코드 보신 분들은 다 아실 것 같고 보기 귀찮으신 분들을 위해서 짧게 적어 봅니다.
[Index Sharding Route] - index settings 에서 number_of_shards 설정 정보를 이용합니다.
- 그래서 각 node 들에 순서데로 나눠서 할당을 합니다.
[Document Route] - sharding 된 index shard 에 document 를 어떻게 분배 할지 결정을 합니다. - 분배는 hash 알고리즘을 이용합니다. - Math.abs( hash(....) % numberOfShards )
관련 소스는 아래 - org.elasticsearch.cluster.routing 패키지 입니다.
Elastic/Elasticsearch 2014. 1. 23. 15:23
원문 : https://speakerdeck.com/elasticsearch/query-optimization-go-more-faster-better
filters are fast, cached, composable, short-circuit no score is calculated, only inclusion / exclusion
term, terms, range query 에 대해 term, terms, range filter 로 대체 하여 사용.
[from]
{ "query" : { "term" : { "field" : "value" } } }
[to]
{ "query" : { "filtered" : { "query" : { "match_all" : {} }, "filter" : { "term" : { "field" : "value" } } } } }
Top level filter is slow.
{ "query" : { … }, "filter" : { … } } Don't use this unless you need it (only useful with facets)
Using Count (더 빠름)
[from]
/{index}/_search { "query" : { … }, "size" : 0 }
[to]
/{index}/_search?search_type=count { "query" : { … } }
Rescore API
1. Query/filter to quickly find top N results 2. Rescore with complex logic to find top 10
Do not EVER use these in a search script.
[to]
_source.field _fields.field
두개 항목은 disk 에서 읽기 때문에 느립니다.
[from] in-memory field data 를 읽기 때문에 빠릅니다.
Elastic/Elasticsearch 2014. 1. 22. 17:25
참고 URL : http://www.elasticsearch.org/overview/logstash/
data.json 파일에 라인 단위로 로그가 쌓이게 되면 이벤트를 받아서 elasticsearch 로 저장 하게 됩니다. json format 이기 떄문에 당연히 field:value 형태로 저장됩니다.
[실행] java -jar logstash-1.3.3-flatjar.jar agent -f logstash-elasticsearch.conf -v
[실행 + 웹UI] java -jar logstash-1.3.3-flatjar.jar agent -f logstash-elasticsearch.conf -v -- web
※ 이렇게 실행 하면 kibana 를 별도로 설치 하지 않으셔도 됩니다. ※ 샘플 데쉬보드 : http://192.168.0.120:9292/index.html#/dashboard/file/guided.json
[logstash-elasticsearch.conf]
input { file { path => "/server/app/logstash/log/data.json" codec => json start_position => "beginning" } }
output { stdout { debug => true debug_format => "json"}
elasticsearch_http { host => "192.168.0.120" port => 9200 } }
※ output 부분에서 stdout 에 설정된 값은 -v 옵션 주고 실행시켰을 때 디버그 메시지를 찍기 위해서 설정 된 것입니다.
[input file]
http://logstash.net/docs/1.3.3/inputs/file input {
file {
add_field => ... # hash (optional), default: {}
codec => ... # codec (optional), default: "plain"
debug => ... # boolean (optional), default: false
discover_interval => ... # number (optional), default: 15
exclude => ... # array (optional)
path => ... # array (required)
sincedb_path => ... # string (optional)
sincedb_write_interval => ... # number (optional), default: 15
start_position => ... # string, one of ["beginning", "end"] (optional), default: "end"
stat_interval => ... # number (optional), default: 1
tags => ... # array (optional)
type => ... # string (optional)
}
}
[output elasticsearch_http] http://logstash.net/docs/13.3/outputs/elasticsearch_http output {
elasticsearch_http {
codec => ... # codec (optional), default: "plain"
document_id => ... # string (optional), default: nil
flush_size => ... # number (optional), default: 100
host => ... # string (required)
idle_flush_time => ... # number (optional), default: 1
index => ... # string (optional), default: "logstash-%{+YYYY.MM.dd}"
index_type => ... # string (optional)
manage_template => ... # boolean (optional), default: true
password => ... # password (optional), default: nil
port => ... # number (optional), default: 9200
replication => ... # string, one of ["async", "sync"] (optional), default: "sync"
template => ... # a valid filesystem path (optional)
template_name => ... # string (optional), default: "logstash"
template_overwrite => ... # boolean (optional), default: false
user => ... # string (optional), default: nil
workers => ... # number (optional), default: 1
}
}
output plugin 에 보면 elasticsearch 도 있는데 이건 테스트 해보니 이미 설치되어 실행 중인 elasticsearch 와 연동하는데 문제가 있는 것 같습니다. 문서 보면 되는 것 처럼 나와 있는데 일단 실패해서 elasticsearch_http 를 이용했습니다.
Elastic/Elasticsearch 2014. 1. 22. 10:42
그냥 elasticsearch.org 블로그 들어가 보시면 있는 내용입니다. 관심 있는 분들은 벌써 아실 내용이긴 한데 그냥 소개해 봅니다.
January 21, 2014
이건 원래도 있던 기능이긴 했는데 그닥 유용하다고 생각 하지 않았습니다. 이번에 나온건 실제 유용하게 사용할 수 있겠더라구요. 일단 지원 하는 repository 를 보면.
Currently, we support file system, S3, Azure and HDFS repositories.
백업 및 복구용으로 활용하세요.
January 20, 2014
간단하게 소개 하면 index 에 대한 disk 용량 관리를 해주는 도구라고 보시면 됩니다. 아마도 logstash 를 사용하시는 분들에게 필요한 도구 일 것 같구요. cron 에 등록해 놓고 사용 하시면 됩니다.
[옵션] $ curator.py -h usage: curator.py [-h] [-v] [--host HOST] [--port PORT] [-t TIMEOUT] [-p PREFIX] [-s SEPARATOR] [-C CURATION_STYLE] [-T TIME_UNIT] [-d DELETE_OLDER] [-c CLOSE_OLDER] [-b BLOOM_OLDER] [-g DISK_SPACE] [--max_num_segments MAX_NUM_SEGMENTS] [-o OPTIMIZE] [-n] [-D] [-l LOG_FILE]
Curator for Elasticsearch indices. Can delete (by space or time), close, disable bloom filters and optimize (forceMerge) your indices.
optional arguments: -h, --help show this help message and exit -v, --version show program version number and exit --host HOST Elasticsearch host. Default: localhost --port PORT Elasticsearch port. Default: 9200 -t TIMEOUT, --timeout TIMEOUT Elasticsearch timeout. Default: 30 -p PREFIX, --prefix PREFIX Prefix for the indices. Indices that do not have this prefix are skipped. Default: logstash- -s SEPARATOR, --separator SEPARATOR Time unit separator. Default: . -C CURATION_STYLE, --curation-style CURATION_STYLE Curate indices by [time, space] Default: time -T TIME_UNIT, --time-unit TIME_UNIT Unit of time to reckon by: [days, hours] Default: days -d DELETE_OLDER, --delete DELETE_OLDER Delete indices older than n TIME_UNITs. -c CLOSE_OLDER, --close CLOSE_OLDER Close indices older than n TIME_UNITs. -b BLOOM_OLDER, --bloom BLOOM_OLDER Disable bloom filter for indices older than n TIME_UNITs. -g DISK_SPACE, --disk-space DISK_SPACE Delete indices beyond n GIGABYTES. --max_num_segments MAX_NUM_SEGMENTS Maximum number of segments, post-optimize. Default: 2 -o OPTIMIZE, --optimize OPTIMIZE Optimize (Lucene forceMerge) indices older than n TIME_UNITs. Must increase timeout to stay connected throughout optimize operation, recommend no less than 3600. -n, --dry-run If true, does not perform any changes to the Elasticsearch indices. -D, --debug Debug mode -l LOG_FILE, --logfile LOG_FILE log file
|