Elasticssearch - Inserting index -Exception - InvalidTypeNameException - message too long


(Vivek) #1

Code is to insert the index into index 'ltables' with the jSON structure as below in the exception trace. Please let me know what iam doing wrong, i do not
want all of the fields to be indexed and hence i executed the mapping as shown below from Kibana manually, before executing the Java code.

So my understanding is that since i have turned off indexing for all fields expect for the ones for which i want as per mapping. Please let me know what do i need to do to store the JSON into index .

Exception in thread "main" InvalidTypeNameException[mapping type name [{"tables":{"dbEntityName":"TFCOMMAREA_HOLD","otherEntityName":null,"entityAttributes":[{"legacyEntityAttributeName":"HOUSEHOLD_NUM","legacyEntAttrCharacteristics":null,"entMiscProp":null,"gwentityAttributeName":"AccountNumber","gwtableName":"pc_account","gwentAttrCharacteristics":null}]}}] is too long; limit is length 255 but was [289]]
at org.elasticsearch.index.mapper.MapperService.merge(MapperService.java:277)
at org.elasticsearch.index.mapper.MapperService.merge(MapperService.java:265)
at org.elasticsearch.cluster.metadata.MetaDataMappingService$2.execute(MetaDataMappingService.java:444)
at org.elasticsearch.cluster.service.InternalClusterService$UpdateTask.run(InternalClusterService.java:388)
at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.runAndClean(PrioritizedEsThreadPoolExecutor.java:231)
at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(PrioritizedEsThreadPoolExecutor.java:194)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

Mapping
PUT ltables
{
"mappings": {
"tables": {
"_all": { "enabled": false },
"properties": {
"dbEntityName": {
"type": "string",
"index": "not_analyzed"
},
"otherEntityName": {
"type": "string",
"index": "not_analyzed"
},
"entityAttributes": {
"type": "nested" ,
"properties": {
"legacyEntityAttributeName": {
"type": "string",
"index": "not_analyzed"
},
"gwentityAttributeName": {
"type": "string",
"index": "not_analyzed"
},
"gwtableName": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
}
}


(Zachary Tong) #2

It looks like there is something wrong with your Java code. The exception is saying that the requested field name was 289 characters, but only 255 characters are allowed. And based on the exception, it appears your code was trying to set this JSON:

{"tables":{"dbEntityName":"TFCOMMAREA_HOLD","otherEntityName":null,"entityAttributes":[{"legacyEntityAttributeName":"HOUSEHOLD_NUM","legacyEntAttrCharacteristics":null,"entMiscProp":null,"gwentityAttributeName":"AccountNumber","gwtableName":"pc_account","gwentAttrCharacteristics":null}]}}

as the name of a field. It looks like your Java code isn't parsing something correctly, and is sending the entire JSON blob as a field name.


(Vivek) #3

Awsome thanks - i know what i did wrong
I was using the prepareIndex method with 2 argumentswhich takes index name and type , in the type i was incorrectly passing the entire Json , which i should have sent in setSource. I was struggling with this for last two days. thanks a lot Zachary,


(system) #4