joonsei
Hello, world!
joonsei
전체 방문자
오늘
어제
  • 분류 전체보기 (32)
    • nodejs (7)
    • javascript (3)
    • Elasticsearch (11)
    • Electron (1)
    • oracle (1)
    • etc (7)
    • MongoDB (1)

인기 글

최근 댓글

최근 글

joonsei
Elasticsearch

Elasticsearch Dynamic Templates

2022. 12. 6. 13:22

Dynamic mapping

색인 필드의 데이터에 대한 data type을 지정하지 않고 동적으로 elasticsearch 에서 적절한 type을 지정해 주는 기능
 mapping type을 미리 선언하지 않고 패턴이나 분석 특성에 맞춰 구성.

match_mapping_type

JSON 파서를 통해서 data type 을 detection 합니다.
long, double 의 경우 integer 와 float 에 대한 정확한 detection 이 어렵기 때문에 항상 long 과 double 로 detection 

match_pattern

이 설정은 위에서 "match":   "s_*" 과 같은 wildcard 패턴을 java 정규식으로 사용하기 위한 설정

 

[ ▼ 데이터 필드명의 prefix 값으로, 데이터 타입을 dynamic type 으로 사용하는 설정 ]

curl -XPUT "localhost:9200/_template/<indexName>?pretty" -H 'Content-Type: application/json' -d' {
"index_patterns": [
"<indexName>"
],
"settings": {
"number_of_shards": 1
},
"mappings": {
"dynamic_templates": [
{
"integers": {
"match": "i_*",
"match_mapping_type": "*",
"mapping": {
"type": "integer"
}
}
},
{
"doubles": {
"match": "d_*",
"match_mapping_type": "*",
"mapping": {
"type": "double"
}
}
},
{
"floats": {
"match": "f_*",
"match_mapping_type": "*",
"mapping": {
"type": "float"
}
}
},
{
"booleans": {
"match": "b_*",
"match_mapping_type": "*",
"mapping": {
"type": "boolean"
}
}
},
{
"longs": {
"match": "l_*",
"match_mapping_type": "*",
"mapping": {
"type": "long"
}
}
},
{
"dates": {
"match": "date",
"match_mapping_type": "*",
"mapping": {
"type": "date"
}
}
},
{
"objects": {
"match": "o_*",
"match_mapping_type": "*",
"mapping": {
"type": "object"
}
}
},
{
"nesteds": {
"match": "n_*",
"match_mapping_type": "*",
"mapping": {
"type": "object"
}
}
},
{
"strings": {
"match": "s_*",
"match_mapping_type": "*",
"mapping": {
"type": "text",
"fields": {
"raw": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
},
{
"no_integers": {
"match": "xi_*",
"mapping": {
"type": "integer",
"index": false
}
}
},
{
"no_doubles": {
"match": "xd_*",
"mapping": {
"type": "double",
"index": false
}
}
},
{
"no_floats": {
"match": "xf_*",
"mapping": {
"type": "float",
"index": false
}
}
},
{
"no_booleans": {
"match": "xb_*",
"mapping": {
"type": "boolean",
"index": false
}
}
},
{
"no_longs": {
"match": "xl_*",
"mapping": {
"type": "long",
"index": false
}
}
},
{
"no_dates": {
"match": "xdate",
"mapping": {
"type": "date",
"index": false
}
}
},
{
"no_objects": {
"match": "xo_*",
"mapping": {
"type": "object"
}
}
},
{
"no_nesteds": {
"match": "xn_*",
"mapping": {
"type": "nested"
}
}
},
{
"no_strings": {
"match": "xs_*",
"mapping": {
"type": "text",
"index": false
}
}
}
]
},
"aliases": {}
} '

 

 

저작자표시 (새창열림)
  • Dynamic mapping
'Elasticsearch' 카테고리의 다른 글
  • failed to obtain in-memory shard lock
  • Elasticsearch function_score 스코어 계산
  • index illegal_argument_exception
  • Document 데이터 전체 수정
joonsei
joonsei
IT 개발자의 소소한 기술 이야기.

티스토리툴바

단축키

내 블로그

내 블로그 - 관리자 홈 전환
Q
Q
새 글 쓰기
W
W

블로그 게시글

글 수정 (권한 있는 경우)
E
E
댓글 영역으로 이동
C
C

모든 영역

이 페이지의 URL 복사
S
S
맨 위로 이동
T
T
티스토리 홈 이동
H
H
단축키 안내
Shift + /
⇧ + /

* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.