when i use the es bulk add method , i got this exception following
reason=mapper [Runtime.SystemProperties.file.encoding] of different type, current_type [keyword], merged_type [ObjectMapper]]]]
my index settings and mappings is,
"settings":{ "index.refresh_interval":"1s", "index.number_of_replicas":"'3'", "index.number_of_shards":"'3'" }, "mappings" : { "data" : { "date_detection": true, "_all": { "enabled": true }, "dynamic_templates": [ { "not_analyzed": { "match": "*", "match_mapping_type": "string", "mapping": { "type":"keyword", "index":false } }} ], "properties" : { "timestamp" : { "type" : "date", "format" : "epoch_millis" } } } }
and i use the high rest client to send the request for data.
my client code is
public static void bulkAdd(String clusterName, Index index, JSONObject object) { long start = System.currentTimeMillis(); String indexName = getIndex(clusterName, index); BulkRequest request = new BulkRequest(); if (object.isEmpty()) { return; } RestClient restClient = getClient(); try { RestHighLevelClient client = new RestHighLevelClient(restClient); for (String key : object.keySet()) { XContentParser parser = XContentFactory.xContent(XContentType.JSON). createParser(NamedXContentRegistry.EMPTY, object.getString(key)); IndexRequest indexRequest = new IndexRequest(indexName, INDEX_TYPE,key).source(parser.map(),XContentType.JSON); request.add(indexRequest); } BulkResponse response = client.bulk(request); if (response.hasFailures()) { log.error("Get exceptions while bulkAdd index " + indexName + ": " + response.buildFailureMessage()); } log.debug("es bulkAdd ... index = " + indexName + ", count = " + object.size() + ", cost = " + (System.currentTimeMillis() - start)); } catch (IOException e) { e.printStackTrace(); } finally { releaseClient(restClient); } }
please help me as soon as possible, i need you help so hurry :