[elasticsearch] Java API : settings property.

Elastic/Elasticsearch 2013. 4. 16. 10:54

본 문서는 개인적인 테스트와 elasticsearch.org 그리고 community 등을 참고해서 작성된 것이며,

정보 교환이 목적입니다.


잘못된 부분에 대해서는 지적 부탁 드립니다.

(예시 코드는 성능 및 보안 검증이 되지 않았습니다.)



[elasticsearch java api 리뷰]

원문 링크

http://www.elasticsearch.org/guide/reference/modules/

http://www.elasticsearch.org/guide/reference/index-modules/

http://www.elasticsearch.org/guide/reference/api/admin-indices-update-settings/



이번 문서는 Java API에서도 제공하고 있는 settings 관련 설정 값들 입니다.


물론 cluster.settings 와 index.settings 도 있기 때문에 모두 확인을 하셔야 합니다.

보통 cluster 와 index 에 대한 설정들은 모두 global setting 을 사용하도록 구성 하기 때문에 elasticsearch.yml 을 구성 할 때 활용 하시면 됩니다.


업데이트 세팅과 작성된 JSON 형식의 예제를 확인해 보도록 하겠습니다.


[admin indices update settings]

SettingDescription
index.number_of_replicasThe number of replicas each shard has.
index.auto_expand_replicasSet to an actual value (like 0-all) or false to disable it.
index.blocks.read_onlySet to true to have the index read only. false to allow writes and metadata changes.
index.blocks.readSet to true to disable read operations against the index.
index.blocks.writeSet to true to disable write operations against the index.
index.blocks.metadataSet to true to disable metadata operations against the index.
index.refresh_intervalThe async refresh interval of a shard.
index.term_index_intervalThe Lucene index term interval. Only applies to newly created docs.
index.term_index_divisorThe Lucene reader term index divisor.
index.translog.flush_threshold_opsWhen to flush based on operations.
index.translog.flush_threshold_sizeWhen to flush based on translog (bytes) size.
index.translog.flush_threshold_periodWhen to flush based on a period of not flushing.
index.translog.disable_flushDisables flushing. Note, should be set for a short interval and then enabled.
index.cache.filter.max_sizeThe maximum size of filter cache (per segment in shard). Set to -1 to disable.
index.cache.filter.expireThe expire after access time for filter cache. Set to -1 to disable.
index.gateway.snapshot_intervalThe gateway snapshot interval (only applies to shared gateways).
merge policyAll the settings for the merge policy currently configured. A different merge policy can’t be set.
index.routing.allocation.include.*A node matching any rule will be allowed to host shards from the index.
index.routing.allocation.exclude.*A node matching any rule will NOT be allowed to host shards from the index.
index.routing.allocation.require.*Only nodes matching all rules will be allowed to host shards from the index.
index.routing.allocation.total_shards_per_nodeControls the total number of shards allowed to be allocated on a single node. Defaults to unbounded.
index.recovery.initial_shardsWhen using local gateway a particular shard is recovered only if there can be allocated quorum shards in the cluster. It can be set to quorum (default), quorum-1 (or half), full and full-1. Number values are also supported, e.g. 1.
index.gc_deletes
index.ttl.disable_purgeDisables temporarily the purge of expired docs.

이 세팅 값들은 서비스 특성에 맞게 구성을 하셔야 합니다.

아래는 위 속성들에 대한 참고용 입니다.


[Sample JSON String]

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

    "settings" : {

        "number_of_shards" : 5,

        "number_of_replicas" : 1,

        "index" : {

            "analysis" : {

                "analyzer" : {

                    "default" : {

                        "type" : "standard",

                        "tokenizer" : "standard",

                        "filter" : ["lowercase", "trim"]

                    },

                    "default_index" : {

                        "type" : "standard",

                        "tokenizer" : "standard",

                        "filter" : ["lowercase", "trim"]

                    },

                    "default_search" : {

                        "type" : "standard",

                        "tokenizer" : "standard",

                        "filter" : ["lowercase", "trim"]

                    },

                    "my_analyzer1" : {

                        "tokenizer" : "standard",

                        "filter" : ["standard", "lowercase", "trim"]

                    },

                    "my_analyzer2" : {

                        "type" : "custom",

                        "tokenizer" : "tokenizer1",

                        "filter" : ["filter1", "trim"]

                    }

                },

                "tokenizer" : {

                    "tokenizer1" : {

                        "type" : "standard",

                        "max_token_length" : 255

                    }

                },

                "filter" : {

                    "filter1" : {

                        "type" : "lowercase",

                        "language" : "greek"

                    }

                }

            },

            "compound_format" : false,

            "merge" : {

                "policy" : {

                    "max_merge_at_once" : 10,

                    "segments_per_tier" : 20

                }

            },

            "refresh_interval" : "1s",

            "term_index_interval" : 1,

            "store" : {

                "type" : "mmapfs",

                "compress" : {

                    "stored" : true,

                    "tv" : true

                }

            }

        }

    }

}'


- 위 표에 없는 설정에 대해서만 기술 합니다.


 number_of_shards

 색인 파일에 대한 shard 수

 index.analysis.analyzer
    .default

    .default_index

    .default_search

    .my_analyzer1

    .my_analyzer2

    .tokenizer

    .filter

색인 및 검색 시 사용할 분석기를 등록함 

    .default* 은 기본 분석기를 등록 index/type 에 대한 기본 설정으로 동작

    .my_analyzer* 은 사용자 정의 분석기

    .tokenizer 와 .filter 는 analyzer 에서 사용하게 될 tokenizer 와 filter 를 정의

 index.compound_format

 파일 기반 저장 시스템을 사용할 경우 false 로 설정해야 더 나은 성능을 지원함

 index.store.type

 

 index.store.compress
    .stored

    .tv

 색인 저장 시 압축 기능에 대한 설정

    . 64KB 이하의 작은 문서에 대한 압축 효과가 좋음



: