在我的弹性搜索中,每个文件都采用以下格式
{
"_index" : "logstash-2014.08.11",
"_type" : "apache-error",
"_id" : "b9vZxg-wRbudJbsV6-vD-A",
"_score" : 1.0,
"_source" : {
"@version":"1",
"@timestamp":"2014-08-11T02:07:26.000Z",
"host":"127.0.0.1:49558",
"type":"apache-error",
"loglevel":"error",
"clientip":"123.12.12.12",
"errormsg":"htaccess: require valid-user not given a valid session, are you using lazy sessions?",
"timestamp_submitted":"2014-08-14 19:25:11 UTC",
"geoip":{"ip":"123.12.12.12"
"country_code2":"US",
"country_code3":"USA",
"country_name":"United States",
"continent_code":"NA",
"latitude":38.0,
"longitude":-97.0,
"dma_code":0,
"area_code":0,
"location":[-97.0,38.0]
}
}
}
我想写一个查询,其中 geoip 中的 country_code2 等于 US
当我尝试在 geoip.ip 上运行查询时,查询正在完美执行,即使对于 geo.latitude 也可以正常工作,但是当我尝试为 geo.country_code2 运行时,我没有得到任何结果。下面是我正在使用的查询
curl -XGET http://abcd.dev:9200/_search?pretty=true -d
{
"query":{
"term":{
"geoip.ip":"123.12.12.12"
}
},
"filter":{
"range":{
"@timestamp":{
"gte":"2014-08-12","lte":"now
}
}
}
}
我没有得到任何结果的实际查询
curl -XGET http://abcd.dev:9200/_search?pretty=true -d
{
"query":{
"term":{
"geoip.country_code2":"US"
}
},
"filter":{
"range":{
"@timestamp":{
"gte":"2014-08-12","lte":"now
}
}
}
}