[英]How to get documents with non-null field in Elastic search?
我有這個查詢,它給我使用過濾器的文檔。 如何確保坐標字段不為空/空?
{
"size":1,
"_source": ["coordinates"]
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"range": {
"timestamp_ms": {
"gte": "1468015200000",
"lte": "1468022400000"
}
}
}
}
}
}
輸出:
{
"took" : 41,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 79112,
"max_score" : 1.0,
"hits" : [ {
"_index" : "twitter",
"_type" : "tweet",
"_id" : "751536344866910208",
"_score" : 1.0,
"_source" : {
"coordinates" : null
}
} ]
}
}
這是映射:
"coordinates" : {
"properties" : {
"coordinates" : {
"type" : "geo_point"
},
"type" : {
"type" : "string",
"index" : "not_analyzed"
}
}
}
您可以在過濾器中添加/查詢過濾器存在
一個例子:
{
"size": 1,
"_source": [
"coordinates"
],
"query": {
"filtered": {
"query": {
"exists": {
"field": "coordinates"
}
},
"filter": {
"range": {
"timestamp_ms": {
"gte": "1468015200000",
"lte": "1468022400000"
}
}
}
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.