1

我正在尝试在 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

请让我知道我哪里出错了。

4

1 回答 1

1

我按照你说的试过了,但是没有用。经过大量试验和错误后,我意识到我的映射不正确。我终于写了正确的映射,现在它可以正常工作了。Jobid 和 TenantId 被 Kibana 识别为数字。我是 JSON、kibana、Bulk、Elastic 的新手,所以需要时间来了解映射的工作原理。

于 2018-06-25T04:37:50.403 回答