不工作我有一個外部JSON模板文件加載到ElasticSearch模板文件中ElasticSearch
這是我做的:
curl -XPUT 'http://localhost:9200/_template/mytemplate' -d @file.json
命令得到正確認識
不幸的是,當指數創建我的JSON文件中定義的規則並不適用
編輯
這是JSON文件
{
"template" : "log-*",
"settings": {
"index": {
"number_of_shards": 1,
"number_of_replicas": 0
}
},
"mappings": {
"logEvent": {
"properties": {
"timeStamp": {
"type": "date",
"format": "dateOptionalTime"
},
"message": {
"type": "string"
},
"messageObject": {
"type": "object"
},
"exception": {
"type": "object"
},
"loggerName": {
"type": "string"
},
"domain": {
"type": "string"
},
"identity": {
"type": "string"
},
"level": {
"type": "string"
},
"className": {
"type": "string"
},
"fileName": {
"type": "string"
},
"lineNumber": {
"type": "long"
},
"fullInfo": {
"type": "string"
},
"methodName": {
"type": "string"
},
"fix": {
"type": "string"
},
"userName": {
"type": "string"
},
"threadName": {
"type": "string"
},
"hostName": {
"type": "string"
}
}
}
}
}
應該被應用到任何折射率匹配log-*
。其中一個索引是log-2016.07.28
該模板指定了lineNumber
的類型。它應該將lineNumber
字段的類型從默認的string
更改爲long
。我得到的文件是lineNumber
作爲string
。
這是返回的文檔:
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [ {
"_index" : "log-2016.07.28",
"_type" : "logEvent",
"_id" : "AVYwvw-k6GHUP7T-sYlL",
"_score" : 1.0,
"_source" : {
"timeStamp" : "2016-07-28T09:04:02.8994786Z",
"message" : "Upload file operation took 600 ms",
"messageObject" : { },
"exception" : { },
"loggerName" : "Reviewer.Web.WebApi.GroupsController",
"domain" : "/LM/W3SVC/2/ROOT-1-131141667495593380",
"identity" : "",
"level" : "INFO",
"className" : "Reviewer.Logger.MethodTimer",
"fileName" : "MethodTimer.cs",
"lineNumber" : "49",
"fullInfo" : "MethodTimer.cs:49)",
"methodName" : "Dispose",
"fix" : "LocationInfo, UserName, Identity, Partial",
"properties" : {
"test" : "123",
"log4net:HostName" : "GBWOTIOM68052D",
"IP" : "::1",
"log4net:Identity" : "",
"log4net:UserName" : "CORP\\gianluca.ghettini",
"log4net:ElapsedTime" : "600",
"@timestamp" : "2016-07-28T09:04:02.8994786Z"
},
"userName" : "CORP\\gianluca.ghettini",
"threadName" : "198",
"hostName" : "GBWOTIOM68052D"
}
} ]
}
}
,你可以看到
"lineNumber" : "49",
仍然是一個string
代替long
那麼你怎麼指標,什麼是錯的,即
"lineNumber": 49
呢? – alpert你能告訴你如何索引你的日誌文件嗎?請顯示一個示例文檔。 – Val
我剛剛添加了一個示例文檔,我想要什麼,而我實際得到的是什麼 –