Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mapper [hits] cannot be changed from type [long] to [integer] #9888

Closed
Hronom opened this issue Jan 16, 2017 · 10 comments
Closed

mapper [hits] cannot be changed from type [long] to [integer] #9888

Hronom opened this issue Jan 16, 2017 · 10 comments
Labels
bug Fixes for quality problems that affect the customer experience Team:Operations Team label for Operations Team

Comments

@Hronom
Copy link

Hronom commented Jan 16, 2017

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.

@mdunnio
Copy link

mdunnio commented Feb 27, 2017

+1

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

@mdunnio
Copy link

mdunnio commented Feb 27, 2017

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"}}}}}
}'

@aboutte
Copy link

aboutte commented Mar 2, 2017

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.

@jbudz jbudz added Team:Operations Team label for Operations Team bug Fixes for quality problems that affect the customer experience and removed :Management labels Apr 3, 2017
@jbudz
Copy link
Member

jbudz commented Apr 28, 2017

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"
        }
      }
    }    
  }
}'
  1. Reindex
curl -XPOST "http://localhost:9200/_reindex" -H 'Content-Type: application/json' -d'
{
  "source": {
    "index": ".kibana"
  },
  "dest": {
    "index": ".kibana-5.x"
  }
}'
  1. In kibana.yml change kibana.index: .kibana-5.x

@Hronom
Copy link
Author

Hronom commented Apr 28, 2017

@jbudz Finally, awesome thanks! Waiting version with fix

@thekofimensah
Copy link

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

@tylersmalley
Copy link
Contributor

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.

@ericrdgz
Copy link

This worked for me, thanks!

@NilsGriebner
Copy link

Works for me, too. Thanks.

@tylersmalley
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience Team:Operations Team label for Operations Team
Projects
None yet
Development

No branches or pull requests

9 participants