[CLOSED] It was my mistake, there are other code that called save() prior to init(). Changing the order fixes this exception.
I'm completely new to ES, trying out ES 6.2.3 with ES DSL 6.2.1 (official client lib for Python). Referring to documentation, I defined below model by using Document.
class Company(Document):
hq_country_iso = Keyword()
co_name = Text()
class Index:
name = 'company'
def save(self, **kwargs):
return super(Company, self).save(**kwargs)
When calling Company.init() of Document API to create index, ES throws below exception. However, the index is still created and I'm able store data into ES (I haven't try production mode though). If I remove the hq_country_iso KEYWORD field or change it as TEXT field, this exception will go away. I'd tried following but have no luck:
- ensured that the index doesn't exist (the word current_type in error msg is beyond my comprehension)
- cleared cache
- restarted ES
Any clue what could be causing this? Thanks.
[2018-08-30T21:32:48,405][DEBUG][o.e.a.a.i.m.p.TransportPutMappingAction] [wm_PvYm] failed to put mappings on indices [[[company/-MEgVBzSSY6GmizoYSJgdg]]], type [doc]
java.lang.IllegalArgumentException: mapper [hq_country_iso] of different type, current_type [text], merged_type [keyword]
at org.elasticsearch.index.mapper.FieldMapper.doMerge(FieldMapper.java:354) ~[elasticsearch-6.2.3.jar:6.2.3]
at org.elasticsearch.index.mapper.TextFieldMapper.doMerge(TextFieldMapper.java:372) ~[elasticsearch-6.2.3.jar:6.2.3]
at org.elasticsearch.index.mapper.FieldMapper.merge(FieldMapper.java:340) ~[elasticsearch-6.2.3.jar:6.2.3]
at org.elasticsearch.index.mapper.FieldMapper.merge(FieldMapper.java:52) ~[elasticsearch-6.2.3.jar:6.2.3]
at org.elasticsearch.index.mapper.ObjectMapper.doMerge(ObjectMapper.java:477) ~[elasticsearch-6.2.3.jar:6.2.3]
at org.elasticsearch.index.mapper.RootObjectMapper.doMerge(RootObjectMapper.java:277) ~[elasticsearch-6.2.3.jar:6.2.3]
at org.elasticsearch.index.mapper.ObjectMapper.merge(ObjectMapper.java:449) ~[elasticsearch-6.2.3.jar:6.2.3]
at org.elasticsearch.index.mapper.RootObjectMapper.merge(RootObjectMapper.java:272) ~[elasticsearch-6.2.3.jar:6.2.3]
at org.elasticsearch.index.mapper.Mapping.merge(Mapping.java:89) ~[elasticsearch-6.2.3.jar:6.2.3]
at org.elasticsearch.index.mapper.DocumentMapper.merge(DocumentMapper.java:304) ~[elasticsearch-6.2.3.jar:6.2.3]
at org.elasticsearch.cluster.metadata.MetaDataMappingService$PutMappingExecutor.applyRequest(MetaDataMappingService.java:267) ~[elasticsearch-6.2.3.jar:6.2.3]
at org.elasticsearch.cluster.metadata.MetaDataMappingService$PutMappingExecutor.execute(MetaDataMappingService.java:230) ~[elasticsearch-6.2.3.jar:6.2.3]
at org.elasticsearch.cluster.service.MasterService.executeTasks(MasterService.java:643) ~[elasticsearch-6.2.3.jar:6.2.3]