[Elasticsearch] Dynamic template - _default_ deprecated.

Elastic/Elasticsearch 2018. 7. 25. 09:49

늘 그렇지만 다 기억 못합니다.


https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-templates.html

https://www.elastic.co/guide/en/elasticsearch/reference/current/default-mapping.html


_default_ 가 deprecated 되었습니다.


이와 더불어 사용시 아래와 같은 에러가 발생을 경험 할 수 있는데요.


org.elasticsearch.index.mapper.MapperParsingException: Failed to parse mapping [_default_]: No field type matched on [integer], possible values are [object, string, long, double, boolean, date, binary]


"mappings": {
"_default_": {
"dynamic_templates": [
{

...중략...

우선  _default_ 는 다른 type name 을 작성해 주시면 됩니다.

원문에서와 같이 _doc 이나 _log 나 default 와 같은...


그리고 저 위에 에러는 dynamic templates 사용 시 field type 정보를 보시면 이해가 되실 겁니다.

우리가 흔히 알고 있는 mapping field type 과 조금 다르기 때문에 잘 인지 하고 계시면 삽질은 피하실 수 있습니다.


https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-templates.html#match-mapping-type


match_mapping_type

The match_mapping_type matches on the datatype detected by dynamic field mapping, in other words, the datatype that Elasticsearch thinks the field should have. Only the following datatypes can be automatically detected: boolean, date, double, long, object, string. It also accepts * to match all datatypes.


더불어서 잘못 생성된 템플릿을 삭제해야 할 필요가 있습니다.

가끔 아래와 같은 에러가 발생 하는데 이럴 경우 템플릿을 삭제 후 다시 등록 하시면 됩니다.


https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html

https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html#delete


java.lang.IllegalArgumentException: Rejecting mapping update to [monitoring-20180725] as the final mapping would have more than 1 type: [log, doc]


DELETE /_template/template_1


: