'mapping'에 해당되는 글 12건

  1. 2013.04.16 [elasticsearch] Java API : mapping property.
  2. 2013.01.16 elasticsearch 색인 생성 스크립트 예제

[elasticsearch] Java API : mapping property.

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

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

정보 교환이 목적입니다.


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

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



[elasticsearch java api 리뷰]

원문 링크

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


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

자세한 설명은 원문의 Fields 와 Types 부분은 꼭 한번 씩 보시기 바랍니다.


[Mapping Template Sample]

    "mapping" : {

        "TYPE_NAME" : {

            "analyzer" : "standard",

            "index_analyzer" : "stadnard",

            "search_analyzer" : "standard",

            "_id" : {

                "index" : "not_analyzed",

                "store" : "yes",

                "path" : "FIELD_NAME"

            },

            "_type" : {

                "index" : "not_analyzed",

                "store" : "yes"

            },

            "_source" : {

                "enabled" : "false"

            },

            "_all" : {

                "enabled" : "false"

            },

            "_boost" : {

                "name" : "_boost",

                "null_value" : 1.0

            },

            "_parent" : {

                "type" : "PARENT_TYPE_NAME"

            },

            "_routing" : {

                "required" : true,

                "path" : "TYPE_NAME.FIELD_NAME"

            },

            "_timestamp" : {

                "enabled" : true,

                "path" : "DATE_FIELD_NAME",

                "format" : "dateOptionalTime"

            },

            "properties" : {

                "FIELD_NAME" : {

                    "type" : "string",

                    "index_name" : ,

                    "store" : ,

                    "index" : ,

                    "term_vector" : ,

                    "boost" : ,

                    "null_value" : ,

                    "omit_norms" : ,

                    "omit_term_freq_and_positions" : ,

                    "index_options" : ,

                    "analyzer" : ,

                    "index_analyzer" : ,

                    "search_analyzer" : ,

                    "include_in_all" : ,

                    "ignore_above" : ,

                    "position_offset_gap" : 

                },

                "FIELD_NAME" : {

                    "type" : "float, double, byte, short, integer, and long",

                    "index_name" : ,

                    "store" : ,

                    "index" : ,

                    "precision_step" : ,

                    "null_value" : ,

                    "boost" : ,

                    "include_in_all" : ,

                    "ignore_malformed" :

                },

                "FIELD_NAME" : {

                    "type" : "date",

                    "index_name" : ,

                    "format" : ,

                    "store" : ,

                    "index" : ,

                    "precision_step" : ,

                    "null_value" : ,

                    "boost" : ,

                    "include_in_all" : ,

                    "ignore_malformed" :

                },

                "FIELD_NAME" : {

                    "type" : "boolean",

                    "index_name" : ,

                    "store" : ,

                    "index" : ,

                    "null_value" : ,

                    "boost" : ,

                    "include_in_all" : ,

                },

                "FIELD_NAME" : {

                    "type" : "binary",

                    "index_name" : ,

                }

            }

        }

    }



[Fields & Core Type]

fields

_id

document 의 unique id 는 _uid (_id + _type) 이며, _id 는 색인 ID 로 사용될 수 있다.

기본적으로 색인되지 않고 저장 하지 않습니다.

_type

기본적으로 색인은 하지만 저장은 하지 않습니다.

_source

자동으로 field 생성을 허용할지 결정 합니다.

_all

하나 또는 더 많은 field 를 색인시 저장 할 것인지 결정을 합니다.

"simple1" : {"type" : "long", "include_in_all" : true},

           "simple2" : {"type" : "long", "include_in_all" : false}

   _analyzer (설정 하지 않아도 되는 field)

    색인 시 등록된 analyzer 또는 index_analyzer 를 사용 합니다.

    또한, 특정 field 를 지정 할 경우 해당 field 에 정의된 analyzer 를 사용하게 됩니다.

   _boost

    문서나 field 의 연관성을 향상시키기 위해 사용한다.

   _parent

    parent type 을 지시하는 child mapping 정의 입니다.

    blog type 과 blog_tag type 이 있을 경우 blog_tag 의 parent type 은 blog 가 됩니다.

_routing

색인 데이터에 대한 routing 관리를 위해서 사용 합니다.

routing field 는 store : yes, index : not_analyzed 로 설정이 되어야 합니다.

_index (설정 하지 않아도 되는 field)

index 가 소유한 문서를 store 합니다.

default false 로 저장 하지 않음.

_size (설정 하지 않아도 되는 field)

_source 에 의해서 자동으로 생성된 색인 field 의 수.

default disabled 입니다.

_timestamp

색인 시 문서의 timestamp 입니다.

기본 store : no, index : not_analyzed 이며,

설정 시 field 지정이 가능 합니다.

format 은 기본 dateOptionalTime. (http://www.elasticsearch.org/guide/reference/mapping/date-format/)

_ttl

색인 시 문서의 expiration date를 설정 합니다.

기본 disabled 입니다.

설정 시 ttl 이후 문서는 자동 삭제 됩니다.

core types

string type

index_name

array type 선언 시 사용되는 항목으로 array list 항목에 대한 개별 field 명으로 사용된다.

store

default no 이며, 저장에 대한 설정을 위해서 사용 된다.

yes 시 저장

index

검색 또는 색인 시 분석관련 설정을 위해서 사용 된다.

analyzed

검색과 색인 시 analyzer 를 이용해서 분석

not_analyzed

검색가능 하다는 의미

no

검색 불가능 하다는 의미

term_vector

기본 no 설정

no

yes

with_offsets

with_positions

with_positions_offsets

boost

기본 1.0

null_value

null value 시 기본 값은 아무것도 넣지 않으나 설정한 값이 있을 경우 등록 함.

omit_norms

기본 false 로 analyzed field 설정, true 일 경우 not_analyzed field 에서 설정

index_options

색인 옵션

docs

not_analyzed field

freqs

analyzed field

positions

analyzed field

analyzer

global 설정으로 검색과 색인 시 사용된다.

index_analyzer

색인 시에 사용된다.

search_analyzer

검색 시에 사용된다.

include_in_all

기본 true 로 설정 됨.

_all field 에 저장할 것인지 지정함.

ignore_above

지정한 크기 이상의 문자열을 무시 합니다.

position_offset_gap

                number type

                    type : "float, double, byte, short, integer, and long",

                    index_name

                    store

                    index

                    precision_step

                        number 의 term value 를 만들어 냅니다.

                        설정 값이 작을 수록 검색은 빠르게 이루어 집니다.

                        기본 값은 4이며, 32bits 는 4 정도, 64bits 는 6~8정도를 사용합니다.

                        0 은 disable 입니다.

                    null_value

                    boost

                    include_in_all

                    ignore_malformed

                        비정상적인 숫자를 무시 한다.

                        기본 false로 설정 되어 있기 때문에 true 설정 하는 것이 좋다.

                date type

                    index_name

                    format

                        http://www.elasticsearch.org/guide/reference/mapping/date-format.html

                    store

                    index

                    precision_step

                        number 의 term value 를 만들어 냅니다.

                        설정 값이 작을 수록 검색은 빠르게 이루어 집니다.

                        기본 값은 4이며, 32bits 는 4 정도, 64bits 는 6~8정도를 사용합니다.

                        0 은 disable 입니다.

                    null_value

                    boost

                    include_in_all

                    ignore_malformed

                        비정상적인 숫자를 무시 한다.

                        기본 false로 설정 되어 있기 때문에 true 설정 하는 것이 좋다.

                boolean type

                    index_name

                    store

                    index

                    null_value

                    boost

                    include_in_all

                binary type

                    index_name

:

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 }

                    }

                }

            }

        }

    }

}'


: