I am getting this error only when I define an Index template on Kibana. I define an index template in order to define a lifecylce policy.
The error is "
failed to put mappings on indices [[]], type [string]
java.lang.IllegalArgumentException: Rejecting mapping update to as the final mapping would have more than 1 type: [_doc, string]"
The index is auto created when first index is created, but as soon as the the data is loaded this error is thrown. I use Java Springboot to push the events to Elastic.
Here is extract of code
> private void sendToElasticSearch(WMQIStatisticsAccounting event) {
> String stringOut = "";
> // Local date time instance
> LocalDateTime localDateTime = LocalDateTime.now();
>
> // Get formatted String
> String ldtString = localDateTime.format(indexDateFormatter);
> String elasticIndexName = indexName + "_" + ldtString;
>
> ObjectMapper objectMapper = new ObjectMapper();
> WMQIStatisticsAccounting eventOut = setEventOut(event);
>
> try {
> stringOut = objectMapper.writeValueAsString(eventOut);
> } catch (JsonProcessingException e2) {
> e2.printStackTrace();
> }
>
> try {
> GetIndexRequest idexRequest = new GetIndexRequest();
> idexRequest.indices(elasticIndexName);
>
> IndexRequest request = new IndexRequest(elasticIndexName);
> request.create(true);
> request.id(UUID.randomUUID().toString());
> request.type("string");
> request.opType(DocWriteRequest.OpType.CREATE);
> request.source(stringOut, XContentType.JSON);
> client.index(request, RequestOptions.DEFAULT);
> log.info("Id : " + request.id());
> } catch (Exception e) {
> throw new RuntimeException("Unable to push event to Elastic : " + e.getMessage());
> }
> }
I have read through all the previous comments that relates to this error and none are applicable.