[elasticsearch] settings & mappings 샘플용 코드...

Elastic/Elasticsearch 2014. 1. 7. 18:41

그냥 참고용으로 올려 놓는 것입니다.

각 속성들은 서비스 특성에 맞춰서 설정 하시는게 좋습니다.


http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-update-settings.html

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-put-mapping.html

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-core-types.html


{
    "settings" : {
        "number_of_shards" : 5,
        "number_of_replicas" : 0,
        "index" : {
            "refresh_interval" : "1s",
            "merge" : {
                "policy" : { "segments_per_tier" : 5 }
            },
            "analysis" : {
                "analyzer" : {
                    "analyzer_standard" : {
                        "type" : "standard",
                        "tokenizer" : "whitespace",
                        "filter" : ["lowercase", "trim"]
                    },
                    "analyzer_pattern" : {
                        "type" : "custom",
                        "tokenizer" : "tokenizer_pattern",
                        "filter" : ["lowercase", "trim"]
                    },
                    "analyzer_ngram" : {
                        "type" : "custom",
                        "tokenizer" : "tokenizer_ngram",
                        "filter" : ["lowercase", "trim"]
                    }
                },
                "tokenizer" : {
                    "tokenizer_ngram" : {
                        "type" : "nGram",
                        "min_gram" : "2",
                        "max_gram" : "10",
                        "token_chars": [ "letter", "digit" ]
                    },
                    "tokenizer_pattern" : {
                        "type" : "pattern",
                        "pattern" : ","
                    }
                }
            },
            "store" : {
                "type" : "mmapfs",
                "compress" : {
                    "stored" : true,
                    "tv" : true
                }
            }
        }
    },
    "mappings" : {
        "INDICE_TYPE_NAME" : {
            "_id" : {
                "index" : "not_analyzed",
                "path" : "KEY_FIELD_NAME"
            },
            "_source" : {
                "enabled" : "true"
            },
            "_all" : {
                "enabled" : "false"
            },
            "_boost" : {
                "name" : "_boost",
                "null_value" : 1.0
            },
            "analyzer" : "analyzer_standard",
            "index_analyzer" : "analyzer_standard",
            "search_analyzer" : "analyzer_standard",
            "properties" : {
                "LONG_KEY_FIELD" : {"type" : "long", "store" : "no", "index" : "not_analyzed",  "omit_norms" : true, "index_options" : "docs", "ignore_malformed" : true, "include_in_all" : false},
                "STRING_SEARCH_FIELD" : {"type" : "string", "store" : "no", "index" : "analyzed", "omit_norms" : false, "index_options" : "offsets", "term_vector" : "with_positions_offsets", "include_in_all" : false},
                "STRING_VIEW_FIELD" : {"type" : "string", "store" : "yes", "index" : "no", "include_in_all" : false},
                "INTEGER_KEY_FIELD" : {"type" : "integer", "store" : "no", "index" : "not_analyzed",  "omit_norms" : true, "index_options" : "docs", "ignore_malformed" : true, "include_in_all" : false},
                "FLOAT_KEY_FIELD" : {"type" : "float", "store" : "no", "index" : "not_analyzed", "omit_norms" : true, "index_options" : "docs", "ignore_malformed" : true, "include_in_all" : false},
                "LONG_VIEW_FIELD" : {"type" : "long", "store" : "yes", "index" : "no",  "ignore_malformed" : true, "include_in_all" : false},
                "STRING_KEY_FIELD" : {"type" : "string", "store" : "no", "index" : "not_analyzed", "omit_norms" : true, "index_options" : "docs", "include_in_all" : false},
                "NESTED_KEY_FIELD" : {"type" : "nested",
                "properties" : {
                    "STRING_KEY_FIELD" : {"type" : "string", "store" : "no", "index" : "not_analyzed", "omit_norms" : true, "index_options" : "docs", "include_in_all" : false},
                    "INTEGER_VIEW_FIELD" : {"type" : "integer", "store" : "yes", "index" : "no",  "ignore_malformed" : true, "include_in_all" : false}
                    }
                },
                "BOOLEAN_VIEW_FIELD" : {"type" : "boolean", "store" : "yes", "include_in_all" : false},
                "BOOLEAN_KEY_FIELD" : {"type" : "boolean", "store" : "no", "index" : "not_analyzed", "omit_norms" : true, "index_options" : "docs", "include_in_all" : false},
                "OBJECT_VIEW_FIELD" : {"type" : "object", "dynamic" : true, "store" : "yes", "index" : "no", "include_in_all" : false}
            }
        }
    }
}






: