I am new to Kibana, have data loaded into Elastic 5.0.0-alpha3 and am using Kibana 5.0.0-alpha3 to Visualise. I can display some numeric fields as histograms but when I want
This code fixes this problem.
PUT megacorp/_mapping/employee
{
"employee": {
"properties": {
"interests": {
"type": "text",
"fielddata": true
}
}
}
}
So this code will run thereafter:
GET /megacorp/employee/_search
{
"aggs": {
"all_interests": {
"terms": { "field": "interests"}
}
}
}
If you are coming from the book "ElasticsearchThe Definitive Guide", try changing this
"terms" : { "field" : "interests" },
to
"terms" : { "field" : "interests.keyword" },
So, the code to run will become;
GET /megacorp/employee/_search
{
"aggs": {
"all_interests": {
"terms": { "field": "interests.keyword"}
}
}
}
In your ES mapping, you need to set fielddata:true in your publisher
field:
PUT your_index/_mapping/your_type
{
"your_type": {
"properties": {
"publisher": {
"type": "text",
"fielddata": true
}
}
}
}
You'll need to reindex your data after making this change, but afterwards Kibana won't complain anymore.
UPDATE
You can either execute the above query in the Sense UI or through curl
curl -XPUT http://localhost:9200/index -d '{
"mappings": {
"type": {
"properties": {
"publisher": {
"type": "text",
"fielddata": true
}
}
}
}
}'
Or you can also execute it in your Javascript file just before creating your document:
client.indices.create({
index: 'index',
body: {
"mappings": {
"type": {
"properties": {
"publisher": {
"type": "text",
"fielddata": true
}
}
}
}
}
});
Since you're using Elastic 5.x (5.2 is out now as I write this), you should instead use the new keyword support instead of enabling fielddata on an indexed field.
https://www.elastic.co/guide/en/elasticsearch/reference/5.2/fielddata.html provides good information on the pros and cons and on how to set this. From the page:
PUT my_index
{
"mappings": {
"my_type": {
"properties": {
"my_field": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword"
}
}
}
}
}
}
}
You then use the 'my_field' field for searches and the 'my_field.keyword' field for aggregations, sorting, or in scripts.
my_field.keyword is what you would use within Kibana / Grafana.
Enable fielddata on an existing text field, this is required to do aggregation on this field
PUT megacorp/_mapping/employee
{
"properties": {
"interests": {
"type": "text",
"fielddata": true
}
}
}