【问题标题】:Elasticsearch: Filter documents with empty geo_point valueElasticsearch:过滤具有空geo_point值的文档
【发布时间】:2016-06-08 21:48:52
【问题描述】:

我正在尝试查询具有空 geo_point 字段的文档的弹性搜索索引。该字段存在但它是空白的(下面的示例)。用于过滤string 字段的查询不适用于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"
      ]
}

【问题讨论】:

    标签: elasticsearch


    【解决方案1】:

    您可以为此使用missing query,它会找到您的文档

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

    【讨论】:

      猜你喜欢
      • 2019-03-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多