我正在尝试在 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 上的 Discover Tab 的样子:1
请让我知道我哪里出错了。