'compression'에 해당되는 글 2건

  1. 2013.01.16 elasticsearch 색인 생성 스크립트 예제
  2. 2013.01.16 Using Elasticsearch for logs - 활용 팁.

elasticsearch 색인 생성 스크립트 예제

Elastic/Elasticsearch 2013. 1. 16. 14:54

그냥 예제 입니다. ㅎㅎ

생성 시 적용된 내용은
- replica 설정
- shards 설정
- refresh interval 설정
- term index interval 설정
- field store 시 compression 설정
- analyzer 설정
- synonym 설정
- routing 설정
- _all disable(?) 설정

# index 삭제

curl -XDELETE 'http://localhost:9200/index0/'


# index 생성

curl -XPUT 'http://localhost:9200/index0' -d '{

    "settings" : {

        "number_of_shards" : 50,

        "number_of_replicas" : 1,

        "index" : {

            "refresh_interval" : "60s",

            "term_index_interval" : "1",

            "store" : {

                "compress" : {

                    "stored" : true,

                    "tv" : true

                }

            },

            "analysis" : {

                "analyzer" : {

                    "kr_analyzer" : {

                        "type" : "custom",

                        "tokenizer" : "kr_tokenizer",

                        "filter" : ["trim", "kr_filter", "kr_synonym"]

                    },

                    "kr_analyzer" : {

                        "type" : "custom",

                        "tokenizer" : "kr_tokenizer",

                        "filter" : ["trim", "kr_filter", "kr_synonym"]

                    }

                },

                "filter" : {

                    "kr_synonym" : {

                        "type" : "synonym",

                        "synonyms_path" : "analysis/synonym.txt"

                    }

                }

            }

        },

        "routing" : {

            "required" : true,

            "path" : "indexType.user_uniq_id"

        }

    },

    "mappings" : {

        "indexType" : {

            "properties" : {

                "docid" : { "type" : "string", "store" : "yes", "index" : "not_analyzed", "include_in_all" : false },

                "rm_seq" : { "type" : "long", "store" : "yes", "index" : "no", "include_in_all" : false },

                "rm_join_seq" : { "type" : "long", "store" : "yes", "index" : "no", "include_in_all" : false },

                "rm_title" : { "type" : "string", "store" : "yes", "index" : "analyzed", "term_vector" : "yes", "analyzer" : "kr_analyzer", "include_in_all" : false },

                "user_uniq_id" : { "type" : "string", "store" : "yes", "index" : "not_analyzed", "include_in_all" : false },

                "mb_nm" : { "type" : "string", "store" : "yes", "index" : "analyzed", "term_vector" : "yes", "analyzer" : "kr_analyzer", "include_in_all" : false },

                "mb_count" : { "type" : "integer", "store" : "yes", "index" : "no", "include_in_all" : false },

                "rm_ymdt" : { "type" : "date", "format" : "yyyyMMddHHmmss", "store" : "yes", "index" : "not_analyzed", "include_in_all" : false },

                "data_size" : { "type" : "long", "store" : "yes", "index" : "no", "include_in_all" : false },

                "msgs" : {

                    "properties" : {

                        "msg_seq" : { "type" : "long", "store" : "no", "index" : "no", "include_in_all" : false },

                        "msg" : { "type" : "string", "store" : "yes", "index" : "analyzed", "term_vector" : "yes", "analyzer" : "kr_analyzer", "include_in_all" : false },

                        "send_user_uniq_id" : { "type" : "string", "store" : "yes", "index" : "not_analyzed", "include_in_all" : false },

                        "send_user_nick_nm" : { "type" : "string", "store" : "yes", "index" : "not_analyzed", "term_vector" : "yes", "analyzer" : "kr_analyzer", "include_in_all" : false },

                        "recv_ymdt" : { "type" : "date", "format" : "yyyyMMddHHmmss", "store" : "yes", "index" : "not_analyzed", "include_in_all" : false },

                        "cfn_yn" : { "type" : "string", "store" : "no", "index" : "no", "include_in_all" : false },

                        "send_yn" : { "type" : "string", "store" : "yes", "index" : "not_analyzed", "include_in_all" : false },

                        "msg_type" : { "type" : "integer", "store" : "yes", "index" : "not_analyzed", "include_in_all" : false }

                    }

                }

            }

        }

    }

}'


:

Using Elasticsearch for logs - 활용 팁.

Elastic/Elasticsearch 2013. 1. 16. 13:20

원문 : http://www.elasticsearch.org/tutorials/2012/05/19/elasticsearch-for-logging.html
번역 : http://socurites.com/122

http://www.elasticsearch.org/guide/reference/api/admin-indices-templates.html

http://www.elasticsearch.org/guide/reference/mapping/source-field.html

http://www.elasticsearch.org/guide/reference/mapping/all-field.html

http://www.elasticsearch.org/guide/reference/query-dsl/

http://www.elasticsearch.org/guide/reference/api/bulk.html


아무래도 이상해서 더 찾아 봤습니다. ㅋㅋ
http://www.elasticsearch.org/guide/reference/index-modules/store.html
이 문서를 보면 일단 _all 과 _source 는 reserved keyword 같구요. (소스 보기 귀찮아서 상상만.. )
문서 보고 store 옵션을 줘서 처리 했습니다.
결과는 ㅎㅎ 성공 ^^

"settings" : {
    "number_of_shards" : 50,
    "number_of_replicas" : 1,
    "index" : {
        "refresh_interval" : "1s",
        "term_index_interval" : "1",
        "store" : {
            "compress" : {
                "stored" : true,
                "tv" : true
            }
        }
    },

    "mappings" : {
        "type명" : {
            "properties" : {               
                "docid" : { "type" : "string", "store" : "yes", "index" : "not_analyzed", "include_in_all" : false },
                "seq" : { "type" : "long", "store" : "yes", "index" : "no", "include_in_all" : false }
            }
        }
    }
}

그리고 _all 에 대해서는 보시는 것 처럼 include_in_all : false 를 해서 _all 로는 어떤것도 매칭이 되지 않습니다.
이건 젤 위 문서에서 all-field.html 보시면 되겠습니다.
참고하시라고 압축율은 무려 80% 나 되내요.. ㅎㅎ


위 링크들 보고 열심히 튜닝 중이긴 한데.. 이게 효과가 있는건지 없는건지 알수가 없내요.. ㅡ.ㅡ;;
(_all, all, _source, source 이건 setting 할때 둘다 적용 되더라구요.)

"all" : {
            "enabled" : false
        },

"source" : {
            "enabled" : true,
        }

용도에 따라 disk 용량을 효율적으로 사용하기 위해서 위와 같은 구성을 했는데.. 흠.. 일단 용량은 조금 줄었는데.. 좀 큰 사이즈로 한번 돌려봐야 겠내요.

데이터 건수가 적은 걸로 돌렸을 때 옵션 안주고 돌리면
- 447MB

옵션주고 돌리면
- 438MB

9MB 절약 되었습니다. ^^;

: