【发布时间】:2016-08-07 06:59:33
【问题描述】:
我正在尝试在 Elasticsearch 中为 JSON 格式的文件创建索引:
{ "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" } }
我希望字段 jobId 和tenantId 是整数。
我在 curl 命令中给出以下映射:
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"}
}
}
}
}
';
这不会给我一个错误。但是,它会创建新的空字段 jobId 和 tenantId 作为整数,并将现有数据作为字符串保存到 attributesInfo.jobId。 systemInfo.tenantId 也是如此。我想在 Kibana 中使用这两个字段进行可视化。我目前无法使用它们,因为它们是空的。
我是 Kibana 和 Elasticsearch 的新手,所以我不确定映射是否正确。
我也尝试了其他几个映射,但它们给出了错误。上面的映射没有报错。
这是 Kibana 上的“发现”选项卡的外观:1
请告诉我哪里出错了。
【问题讨论】:
-
我可以看到 jobId 和tenantId 有字符串值(“40”和“67”)。尝试插入 "jobId"=40 & "tenantId": 67 看看它是否有效。
标签: json elasticsearch mapping kibana-4 elasticsearch-bulk-api