Elasticsearch
[Elasticsearch] dynamic : true / false / runtime / strict 알아보기
알로호모라
2022. 4. 15. 16:42
반응형
Parameters for dynamic
dynamic parameter는 mappings에 설정되지 않은 새로운 fields를 동적으로 추가하지 말지를 정한다.
await client.indices.create({
index: 'test',
body: {
mappings: {
dynamic: false,
properties: {
id: { type: 'keyword' },
title: { type: 'text' },
body: { type: 'text' },
count: { type: 'integer' },
date: { type: 'date' },
tags: { type: 'keyword' }
}
}
}
})
☀️ | |
true (default) | 새로운 필드를 mapping에 추가한다. |
false | new fields들은 무시된다. 이 fileds들은 Index되거나 search 검색되지 않으나 return된 hits에 _source field에 담겨져 있고 보이긴 한다. |
runtime | new fieldssms runtime fields로써 mapping에 추가된다. 하지만 Index되진 않고 _source로부터 loaded될 수는 있다 at query time. |
strict | new fields가 감지되면 exception 예외가 던져지고 document는 거절된다. |
존재하지 않는 인덱스에도 데이터를 넣을 수 있는 Elasticsearch -> 알아서 색인을 생성하기 때문이다. 이러한 기능을 동적 매핑 (dynamic mapping) 이라고 한다. 하지만 실무에서는 데이터 색인 전 매핑 정보를 미리 정의하여 인덱스를 생성하는 것이 성능에 훨씬 좋다고 한다.
reference : https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic.html
dynamic | Elasticsearch Guide [8.1] | Elastic
When you index a document containing a new field, Elasticsearch adds the field dynamically to a document or to inner objects within a document. The following document adds the string field username, the object field name, and two string fields under the na
www.elastic.co
반응형