2016-06-08 44 views
0

我正在嘗試查詢帶有空geo_point字段的文檔的elasticsearch索引。該字段存在,但它是空白的(例如下面)。用於篩選string字段的查詢不適用於geo_point字段。Elasticsearch:過濾具有空geo_point值的文檔

文件:

"_source": { 
"latitudeLongitude": "", 
"pickupLocationZipcode": "", 
} 

查詢過濾字符串字段的作品,但不geo_point領域:

{ 
    "query": { 
    "filtered": { 
     "filter": { 
     "term": { 
      "latitudeLongitude": "" 
     } 
     } 
    } 
    } 
} 

映射:

"latitudeLongitude": { 
    "type": "geo_point" 
} 
"pickupLocationZipcode": { 
    "index": "not_analyzed", 
    "type": "string", 
    "copy_to": [ 
     "pickup_location_zipcode" 
     ] 
} 

回答

0

可以使用missing query,這和它會找到你的文件

{ 
    "query": { 
    "filtered": { 
     "filter": { 
     "missing": { 
      "field": "latitudeLongitude", 
      "existence": false, 
      "null_value": true 
     } 
     } 
    } 
    } 
}