Kibana: mapper [hits] cannot be changed from type [long] to [integer]

Created on 16 Jan 2017  路  10Comments  路  Source: elastic/kibana

Please solve this issue, the full description is here https://discuss.elastic.co/t/discover-tab-wont-load-anymore/38549/25

This happens when you put dashboards and visualizations to .kibana index directly by using ES, not from Kibana UI.

Please let Kibana creates .kibana index from the scratch with correct mapping for fields hits and version, so it will looks like this:

{
  ".kibana": {
    "aliases": {},
    "mappings": {
      "server": {
        "properties": {
          "uuid": {
            "type": "keyword"
          }
        }
      },
      "dashboard": {
        "properties": {
          "description": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "hits": {
            "type": "integer"
          },
          "kibanaSavedObjectMeta": {
            "properties": {
              "searchSourceJSON": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              }
            }
          },
          "optionsJSON": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "panelsJSON": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "timeFrom": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "timeRestore": {
            "type": "boolean"
          },
          "timeTo": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "title": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "uiStateJSON": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "version": {
            "type": "integer"
          }
        }
      },
      "search": {
        "properties": {
          "columns": {
            "type": "text"
          },
          "description": {
            "type": "text"
          },
          "hits": {
            "type": "integer"
          },
          "kibanaSavedObjectMeta": {
            "properties": {
              "searchSourceJSON": {
                "type": "text"
              }
            }
          },
          "sort": {
            "type": "text"
          },
          "title": {
            "type": "text"
          },
          "version": {
            "type": "integer"
          }
        }
      },
      "timelion-sheet": {
        "properties": {
          "description": {
            "type": "text"
          },
          "hits": {
            "type": "integer"
          },
          "kibanaSavedObjectMeta": {
            "properties": {
              "searchSourceJSON": {
                "type": "text"
              }
            }
          },
          "timelion_chart_height": {
            "type": "integer"
          },
          "timelion_columns": {
            "type": "integer"
          },
          "timelion_interval": {
            "type": "text"
          },
          "timelion_other_interval": {
            "type": "text"
          },
          "timelion_rows": {
            "type": "integer"
          },
          "timelion_sheet": {
            "type": "text"
          },
          "title": {
            "type": "text"
          },
          "version": {
            "type": "integer"
          }
        }
      },
      "config": {
        "properties": {
          "buildNum": {
            "type": "keyword"
          },
          "defaultIndex": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          }
        }
      },
      "index-pattern": {
        "properties": {
          "fieldFormatMap": {
            "type": "text"
          },
          "fields": {
            "type": "text"
          },
          "intervalName": {
            "type": "text"
          },
          "notExpandable": {
            "type": "boolean"
          },
          "sourceFilters": {
            "type": "text"
          },
          "timeFieldName": {
            "type": "text"
          },
          "title": {
            "type": "text"
          }
        }
      },
      "visualization": {
        "properties": {
          "description": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "kibanaSavedObjectMeta": {
            "properties": {
              "searchSourceJSON": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              }
            }
          },
          "savedSearchId": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "title": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "uiStateJSON": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "version": {
            "type": "integer"
          },
          "visState": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          }
        }
      }
    },
    "settings": {
      "index": {
        "creation_date": "1484597580045",
        "number_of_shards": "1",
        "number_of_replicas": "1",
        "uuid": "R5XXkVnsQsWZwQewrxsJvg",
        "version": {
          "created": "5010199"
        },
        "provided_name": ".kibana"
      }
    }
  }
}

This is very annoying bug, with this bug the Discover tab cannot be loaded.

Summary:
When Kibana starts and creates .kibana index in ES it didn't put mapping for this index, this is bad for all, who want to put dashboards and visualizations directly in ES, not from Kibana UI.
Because when ES sees new type of document without previously setted mapping it try to recognize type of field in this document and here the problem begins. ES recognize type of fields hits and version like long but Kibana needs integer type.

Operations bug

Most helpful comment

We are working on a fix scheduled for this in 5.6. It's usually caused by incorrect mappings. Kibana in versions < 5.5 pushes mappings as needed from the browser. If you are restoring a kibana index before these mappings have been created, dynamic mappings will be used and won't match what kibana expects causing errors like this.

If you're on 5.x and running into this, as a workaround, I would recommend creating an index template with the correct mappings and then reindexing. Make sure to do backups before, and the steps below are a rough approximation:

1) Create an index template

curl -XPUT "http://localhost:9200/_template/kibana" -H 'Content-Type: application/json' -d'
{
  "template": ".kibana-5*",
  "settings": {
    "number_of_shards": 1
  },
  "mappings": {
    "config": {
      "properties": {
        "buildNum": {
          "type": "keyword"
        }
      }
    },
    "index-pattern": {
      "properties": {
        "fieldFormatMap": {
          "type": "text"
        },
        "fields": {
          "type": "text"
        },
        "intervalName": {
          "type": "keyword"
        },
        "notExpandable": {
          "type": "boolean"
        },
        "sourceFilters": {
          "type": "text"
        },
        "timeFieldName": {
          "type": "keyword"
        },
        "title": {
          "type": "text"
        }
      }
    },
    "visualization": {
      "properties": {
        "description": {
          "type": "text"
        },
        "kibanaSavedObjectMeta": {
          "properties": {
            "searchSourceJSON": {
              "type": "text"
            }
          }
        },
        "savedSearchId": {
          "type": "keyword"
        },
        "title": {
          "type": "text"
        },
        "uiStateJSON": {
          "type": "text"
        },
        "version": {
          "type": "integer"
        },
        "visState": {
          "type": "text"
        }
      }
    },
    "search": {
      "properties": {
        "columns": {
          "type": "keyword"
        },
        "description": {
          "type": "text"
        },
        "hits": {
          "type": "integer"
        },
        "kibanaSavedObjectMeta": {
          "properties": {
            "searchSourceJSON": {
              "type": "text"
            }
          }
        },
        "sort": {
          "type": "keyword"
        },
        "title": {
          "type": "text"
        },
        "version": {
          "type": "integer"
        }
      }
    },
    "dashboard": {
      "properties": {
        "description": {
          "type": "text"
        },
        "hits": {
          "type": "integer"
        },
        "kibanaSavedObjectMeta": {
          "properties": {
            "searchSourceJSON": {
              "type": "text"
            }
          }
        },
        "optionsJSON": {
          "type": "text"
        },
        "panelsJSON": {
          "type": "text"
        },
        "refreshInterval": {
          "properties": {
            "display": {
              "type": "keyword"
            },
            "pause": {
              "type": "boolean"
            },
            "section": {
              "type": "integer"
            },
            "value": {
              "type": "integer"
            }
          }
        },
        "timeFrom": {
          "type": "keyword"
        },
        "timeRestore": {
          "type": "boolean"
        },
        "timeTo": {
          "type": "keyword"
        },
        "title": {
          "type": "text"
        },
        "uiStateJSON": {
          "type": "text"
        },
        "version": {
          "type": "integer"
        }
      }
    },
    "url": {
      "properties": {
        "accessCount": {
          "type": "long"
        },
        "accessDate": {
          "type": "date"
        },
        "createDate": {
          "type": "date"
        },
        "url": {
          "type": "text",
            "fields": {
            "keyword": {
              "type": "keyword",
                "ignore_above": 2048
            }
          }
        }
      }
    },
    "server": {
      "properties": {
        "uuid": {
          "type": "keyword"
        }
      }
    },
    "timelion-sheet": {
      "properties": {
        "description": {
          "type": "text"
        },
        "hits": {
          "type": "integer"
        },
        "kibanaSavedObjectMeta": {
          "properties": {
            "searchSourceJSON": {
              "type": "text"
            }
          }
        },
        "timelion_chart_height": {
          "type": "integer"
        },
        "timelion_columns": {
          "type": "integer"
        },
        "timelion_interval": {
          "type": "keyword"
        },
        "timelion_other_interval": {
          "type": "keyword"
        },
        "timelion_rows": {
          "type": "integer"
        },
        "timelion_sheet": {
          "type": "text"
        },
        "title": {
          "type": "text"
        },
        "version": {
          "type": "integer"
        }
      }
    }    
  }
}'

2) Reindex

curl -XPOST "http://localhost:9200/_reindex" -H 'Content-Type: application/json' -d'
{
  "source": {
    "index": ".kibana"
  },
  "dest": {
    "index": ".kibana-5.x"
  }
}'

3) In kibana.yml change kibana.index: .kibana-5.x

All 10 comments

+1

Are there any temporary solutions to this other than just deleting the .kibana index?

I ended up just doing this:

curl -XDELETE http://ip:port/.kibana

curl -XPUT http://ip:port/.kibana/_mapping/dashboard -d '{"dashboard":{"properties":{"title":{"type":"string"},"hits":{"type":"integer"},"description":{"type":"string"},
"panelsJSON":{"type":"string","optionsJSON":{"type":"string"},"uiStateJSON":{"type":"string"},"version":{"type":"integer"}
"timeRestore":{"type":"boolean"},"timeTo":{"type":"string"},"timeFrom":{"type":"string"},"kibanaSavedObjectMeta":{"properties":{"searchSourceJSON":{"type":"string"}}}}}
}'

For anyone else who runs into this issue I followed the suggestions on this page. Before importing the dashboard I am deleting the hits and version keys for each dashboard element. I have not had any issues since adding that step into my automation.

We are working on a fix scheduled for this in 5.6. It's usually caused by incorrect mappings. Kibana in versions < 5.5 pushes mappings as needed from the browser. If you are restoring a kibana index before these mappings have been created, dynamic mappings will be used and won't match what kibana expects causing errors like this.

If you're on 5.x and running into this, as a workaround, I would recommend creating an index template with the correct mappings and then reindexing. Make sure to do backups before, and the steps below are a rough approximation:

1) Create an index template

curl -XPUT "http://localhost:9200/_template/kibana" -H 'Content-Type: application/json' -d'
{
  "template": ".kibana-5*",
  "settings": {
    "number_of_shards": 1
  },
  "mappings": {
    "config": {
      "properties": {
        "buildNum": {
          "type": "keyword"
        }
      }
    },
    "index-pattern": {
      "properties": {
        "fieldFormatMap": {
          "type": "text"
        },
        "fields": {
          "type": "text"
        },
        "intervalName": {
          "type": "keyword"
        },
        "notExpandable": {
          "type": "boolean"
        },
        "sourceFilters": {
          "type": "text"
        },
        "timeFieldName": {
          "type": "keyword"
        },
        "title": {
          "type": "text"
        }
      }
    },
    "visualization": {
      "properties": {
        "description": {
          "type": "text"
        },
        "kibanaSavedObjectMeta": {
          "properties": {
            "searchSourceJSON": {
              "type": "text"
            }
          }
        },
        "savedSearchId": {
          "type": "keyword"
        },
        "title": {
          "type": "text"
        },
        "uiStateJSON": {
          "type": "text"
        },
        "version": {
          "type": "integer"
        },
        "visState": {
          "type": "text"
        }
      }
    },
    "search": {
      "properties": {
        "columns": {
          "type": "keyword"
        },
        "description": {
          "type": "text"
        },
        "hits": {
          "type": "integer"
        },
        "kibanaSavedObjectMeta": {
          "properties": {
            "searchSourceJSON": {
              "type": "text"
            }
          }
        },
        "sort": {
          "type": "keyword"
        },
        "title": {
          "type": "text"
        },
        "version": {
          "type": "integer"
        }
      }
    },
    "dashboard": {
      "properties": {
        "description": {
          "type": "text"
        },
        "hits": {
          "type": "integer"
        },
        "kibanaSavedObjectMeta": {
          "properties": {
            "searchSourceJSON": {
              "type": "text"
            }
          }
        },
        "optionsJSON": {
          "type": "text"
        },
        "panelsJSON": {
          "type": "text"
        },
        "refreshInterval": {
          "properties": {
            "display": {
              "type": "keyword"
            },
            "pause": {
              "type": "boolean"
            },
            "section": {
              "type": "integer"
            },
            "value": {
              "type": "integer"
            }
          }
        },
        "timeFrom": {
          "type": "keyword"
        },
        "timeRestore": {
          "type": "boolean"
        },
        "timeTo": {
          "type": "keyword"
        },
        "title": {
          "type": "text"
        },
        "uiStateJSON": {
          "type": "text"
        },
        "version": {
          "type": "integer"
        }
      }
    },
    "url": {
      "properties": {
        "accessCount": {
          "type": "long"
        },
        "accessDate": {
          "type": "date"
        },
        "createDate": {
          "type": "date"
        },
        "url": {
          "type": "text",
            "fields": {
            "keyword": {
              "type": "keyword",
                "ignore_above": 2048
            }
          }
        }
      }
    },
    "server": {
      "properties": {
        "uuid": {
          "type": "keyword"
        }
      }
    },
    "timelion-sheet": {
      "properties": {
        "description": {
          "type": "text"
        },
        "hits": {
          "type": "integer"
        },
        "kibanaSavedObjectMeta": {
          "properties": {
            "searchSourceJSON": {
              "type": "text"
            }
          }
        },
        "timelion_chart_height": {
          "type": "integer"
        },
        "timelion_columns": {
          "type": "integer"
        },
        "timelion_interval": {
          "type": "keyword"
        },
        "timelion_other_interval": {
          "type": "keyword"
        },
        "timelion_rows": {
          "type": "integer"
        },
        "timelion_sheet": {
          "type": "text"
        },
        "title": {
          "type": "text"
        },
        "version": {
          "type": "integer"
        }
      }
    }    
  }
}'

2) Reindex

curl -XPOST "http://localhost:9200/_reindex" -H 'Content-Type: application/json' -d'
{
  "source": {
    "index": ".kibana"
  },
  "dest": {
    "index": ".kibana-5.x"
  }
}'

3) In kibana.yml change kibana.index: .kibana-5.x

@jbudz Finally, awesome thanks! Waiting version with fix

The work around works great! Thanks for posting it :)

This should not be an issue starting in 6.0 as we only have a single type and this issue is related to the same field name across document types have a different field type.

This worked for me, thanks!

Works for me, too. Thanks.

Closing as this should be a non-issue as of 6.0

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bradvido picture bradvido  路  3Comments

cafuego picture cafuego  路  3Comments

timroes picture timroes  路  3Comments

celesteking picture celesteking  路  3Comments

Ginja picture Ginja  路  3Comments