Website content quality is poor, distribution efficiency is too low how to do?Huawei engineers offer 5 unique skills>>>
An error was reported in the ES client test file written today. The method body is as follows:
the
publicIndexResponsecreateIndex(StringindexName,Stringtype,
StringjsonArray){
IndexRequestBuilderbuilder=client.prepareIndex(indexName,type).setSource(jsonArray);
IndexResponseresponse=builder.execute().actionGet();
returnresponse;
}
The contents of the error report are as follows:
Exceptioninthread"main"MapperParsingException[failedtoparse];nested:NotSerializableExceptionWrapper[not_x_content_exception:Compressordetectioncanonlybecalledonsomexcontentbytesorcompressedxcontentbytes];
atorg.elasticsearch.index.mapper.DocumentParser.parseDocument(DocumentParser.java:154)
atorg.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:309)
atorg.elasticsearch.index.shard.IndexShard.prepareCreate(IndexShard.java:529)
atorg.elasticsearch.index.shard.IndexShard.prepareCreateOnPrimary(IndexShard.java:506)
atorg.elasticsearch.action.index.TransportIndexAction.prepareIndexOperationOnPrimary(TransportIndexAction.java:215)
atorg.elasticsearch.action.index.TransportIndexAction.executeIndexRequestOnPrimary(TransportIndexAction.java:224)
atorg.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:158)
atorg.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:66)
atorg.elasticsearch.action.support.replication.TransportReplicationAction$PrimaryPhase.doRun(TransportReplicationAction.java:639)
atorg.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
atorg.elasticsearch.action.support.replication.TransportReplicationAction$PrimaryOperationTransportHandler.messageReceived(TransportReplicationAction.java:279)
atorg.elasticsearch.action.support.replication.TransportReplicationAction$PrimaryOperationTransportHandler.messageReceived(TransportReplicationAction.java:271)
atorg.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:75)
atorg.elasticsearch.transport.TransportService$4.doRun(TransportService.java:376)
atorg.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
atjava.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
atjava.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
atjava.lang.Thread.run(Thread.java:745)
Causedby:NotSerializableExceptionWrapper[not_x_content_exception:Compressordetectioncanonlybecalledonsomexcontentbytesorcompressedxcontentbytes]
atorg.elasticsearch.common.compress.CompressorFactory.compressor(CompressorFactory.java:85)
atorg.elasticsearch.common.xcontent.XContentHelper.createParser(XContentHelper.java:50)
atorg.elasticsearch.index.mapper.DocumentParser.parseDocument(DocumentParser.java:90)
...17more
The reason for this exception is that the format of the passed parameter jsonarray is not correct. I printed the following jsonarray format:
[{"name":"hui1","salary":10000.39982635574,"age":8},
{"name":"hui2","salary":10000.160206564933,"age":11},
{"name":"hui3","salary":10000.417013742277,"age":28},
{"name":"hui4","salary":10000.26786620842,"age":7}]
The correct format here should be as follows:
{"name":"hui1","salary":10000.39982635574,"age":8}
Even if the original “[” switch jsonarray “[” is changed to this:
{"name":"hui1","salary":10000.39982635574,"age":8},
{"name":"hui2","salary":10000.160206564933,"age":11},
{"name":"hui3","salary":10000.417013742277,"age":28},
{"name":"hui4","salary":10000.26786620842,"age":7}
It’s also a mistake
Similar Posts:
- java.net.NoRouteToHostException: No route to host
- [Solved] mybatis Multi-Module Error: Invalid bound statement (not found)
- [Solved] Hadoop running jar package error: java.lang.exception: java.lang.arrayindexoutofboundsexception: 1
- [Solved] reason”: “Root mapping definition has unsupported parameters:
- How to quickly locate problems in error reporting of db2-407 sqlcode: – 407, sqlstate: 23502
- How to quickly locate problems in error reporting of db2-407 sqlcode: – 407, sqlstate: 23502
- [Solved] tomcat at org.apache.tomcat.util.buf.CharChunk.append(CharChunk.java:355)
- [Solved] Invalid character found in method name. HTTP method names must be tokens
- [Solved] Flume startup error: org.apache.flume.FlumeException: Failed to set up server socket
- [Solved] java.lang.IllegalStateException: Failed to introspect Class xxxx