關于 ElasticSearch 的新手問題:
我有以下資料http://localhost:9200/tutorial/_doc/7:
"_index":"tutorial","_type":"_doc","_id":"7","_version":3,"_seq_no":25,"_primary_term":2,"found":true,
"_source":{
"message": "error",
"@timestamp": "2022-05-16T09:40:00"
}
我正在嘗試查找所有具有以下請求的@timestamp記錄:2022-05-16T09:30:002022-05-16T09:50:00
POST http://localhost:9200/tutorial/_search
Content-Type: application/json
{
"query": {
"bool": {
"filter": {
"bool": {
"must": [
{
"range": {
"@timestamp.keyword": {
"gt": "2022-05-16T09:30:00",
"lte": "2022-05-16T09:50:00"
}
}
}
]
}
}
}
}
}
我的問題是,為什么我必須使用@timestamp.keyword但不僅僅是@timestamp為了下面的值range?如果我使用沒有 的那個keyword,我將一無所獲。
有點背景關系,我正在設定需要一個@timestamp欄位的 Elastalert。我檢查了它發送到 ElasticSearch 的請求是否@timestamp作為沒有 的范圍keyword,因此它沒有給我任何價值。
結果http://localhost:9200/tutorial是否有幫助:
{
"tutorial":{
"aliases":{
},
"mappings":{
"properties":{
"@timestamp":{
"type":"text",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
},
"fielddata":true
},
"message":{
"type":"text",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
}
}
},
"settings":{
"index":{
"routing":{
"allocation":{
"include":{
"_tier_preference":"data_content"
}
}
},
"number_of_shards":"1",
"provided_name":"tutorial",
"creation_date":"1652405360958",
"number_of_replicas":"1",
"uuid":"OuynpaOiRyqQ1sj-b2xuYw",
"version":{
"created":"7170399"
}
}
}
}
}
uj5u.com熱心網友回復:
您的@timestamp欄位未正確映射,因為text/keyword欄位型別不適用于日期值。您需要將映射更改為此:
"@timestamp":{
"type":"date"
},
然后你就可以運行你的range查詢@timestamp
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/476426.html
上一篇:我如何理解由于elasticsearch中的should查詢而回傳的檔案是通過哪個查詢回傳的?
下一篇:如何訂購帶有模糊性的完成建議
