[elasticsearch] mapping 분석 및 이해.

Elastic/Elasticsearch 2013. 5. 22. 18:24

elasticsearch 에서 성능 및 운영에 있어서 기본이면서 핵심 내용이 될 수 있는 정보 입니다.

사실 이 내용만 잘 이해 하고 있으면 50% 이상 먹고 들어 갈 수 있습니다. ^^


mapping section

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


fields 와 types 를 확인해야 함.

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



default mapping template

"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" : ,

}

}

}

}


: