Can’t merge a non object mapping with an object mapping error in machine learning(beta) module
Asked Answered
F

2

12

I'm trying out the new machine learning module in x pack. I'm trying to identify rare response codes in HTTP Access logs in time. My logs are being stored in elasticsearch as below:

{
  "_index": "logstash-2017.05.18",
  "_type": "Accesslog",
  "_id": "AVxvVfFGdMmRr-0X-J5P",
  "_version": 1,
  "_score": null,
  "_source": {
    "request": "/web/Q123/images/buttons/asdf.gif",
    "server": "91",
    "auth": "-",
    "ident": "-",
    "verb": "GET",
    "type": "Accesslog",
    "path": "/path/to/log",
    "@timestamp": "2017-05-18T10:20:00.000Z",
    "response": "304",
    "clientip": "1.1.1.1",
    "@version": "1",
    "host": "ip-10-10-10-10",
    "httpversion": "1.1",
    "timestamp": "18/May/2017:10:20:00 +0530"
  },
  "fields": {
    "@timestamp": [
      1495102800000
    ]
  }

I added a detector where I selected the function as 'rare' and the by_field_name' as 'response'. But when I save the job I get the following error:

Save failed: [illegal_argument_exception] Can't merge a non object mapping [response] with an object mapping [response]

Please help.

Freeboard answered 8/6, 2017 at 12:19 Comment(2)
did you found a solution?Rinarinaldi
Hi...found it...you need to use a dedicated index...detailed answer here discuss.elastic.co/t/…Freeboard
L
7

The error message means that you are trying to change an existing mapping. However, that is not possible in Elasticsearch. Once a mapping has been created, it cannot be changed.

As explained by Shay Banon himself:

You can't change existing mapping type, you need to create a new index with the correct mapping and index the data again.

So you must create a new index to create this mapping. Depending on the situation, you either

  • create an additional index, or
  • delete the current index and re-create it from scratch.

Of course in the latter case you will lose all data in the index, so prepare accordingly.

Leyden answered 27/10, 2017 at 7:27 Comment(0)
A
0

I faced the same problem and found a solution. My problem was that the model in dynamic json had changed, and for one field in which there was no data on my index, I got this solution

  1. I created a new index ( PUT /new-index )
  2. Put in it new mappings ( PUT /new-index/_mapping )
  3. rebase data from old index to new index ( POST _reindex )
  4. delete old index ( DELETE /index )
  5. create old index with new mappings ( PUT /index, PUT /index/_mapping )
  6. rebase data from new index to old index ( POST _reindex )
Agouti answered 13/9, 2023 at 10:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.