jsonelasticsearchmappingkibana-4elasticsearch-bulk-api

How to create an index with integer fields in Elasticsearch for the JSON file of format?


I am trying to create an index in Elasticsearch for the JSON file of format:

{ "index" : { "_index" : "entity", "_type" : "type1", "_id" : "0" } }
{     "eid":"guid of Event autogenerated",     "entityInfo": {         "entityType":"qualityevent",         "defaultLocale":"en-US"     },     "systemInfo":     {         "tenantId":"67"     },     "attributesInfo" : {         "jobId":"21",         "matchStatus": "new"     }      }
{ "index" : { "_index" : "entity", "_type" : "type1", "_id" : "1" } }
{     "eid":"guid of Event autogenerated",     "entityInfo":     {         "entityType":"qualityevent",         "defaultLocale":"en-US"     },     "systemInfo":     {         "tenantId":"67"     },     "attributesInfo" : {         "jobId":"20",         "matchStatus": "existing"     }     }

I want the fields jobId and tenantId to be integers.

I am giving the following mapping in curl command:

curl -XPUT http://localhost:9200/entity -d '
{
    "mappings": {
        "entityInfo":
        {
            "properties" : {
            "entityType" : { "type":"string","index" : "not_analyzed"},
            "defaultLocale":{ "type":"string","index" : "not_analyzed"}
            }
        },
        "systemInfo":
        {
            "properties" : {
            "tenantId": { "type" : "integer" }
            }
        },
        "attributesInfo" : 
        {
            "properties" : {
            "jobId": { "type" : "integer" },
            "matchStatus": { "type":"string","index" : "not_analyzed"}
            }
        }
    }
}
'; 

This does not give me an error. However, it creates new empty fields jobId and tenantId as integers and it keeps the existing data into attributesInfo.jobId as string. Same is the case with systemInfo.tenantId. I want to use these two fields in Kibana for visualization. I currently cannot use them as they are empty.

I am new to Kibana and Elasticsearch so I am not sure if the mapping is correct.

I have tried couple of other mappings as well but they give errors. Above mapping does not give error.

This is how Discover Tab on Kibana looks like: 1

Please let me know where I am going wrong.


Solution

  • I tried as you mentioned but it didn't help. What I realised after a lot of trial and error that my mapping was incorrect. I finally wrote the correct mapping and now it works correctly. Jobid and TenantId are recognised as numbers by Kibana. I am new to JSON, kibana, Bulk, Elastic so it took time to understand how mapping works.