elasticsearch geo distance query failure

时间:2015-05-26 10:29:13

标签: elasticsearch

我对弹性搜索有一点疑问。

我在表格中使用下一个映射。 (geonames表)

{
 "zoek": {
      "mappings": {
         "geo": {
            "properties": {
               "country": {
                  "type": "string"
               },
               "geonameid": {
                  "type": "string"
               },
               "locatie": {
                  "type": "geo_point"
               },
               "name": {
                  "type": "string"
               }
            }
         }
      }
   }
}

“locatie”是double数组的geo_point映射。

所以寻找我们当地的村庄“rhee”很好:

GET /zoek/geo/_search
{
    "query": {
        "match": { "name": "rhee" }
    }
}

答案:

{
   "took": 3,
   "timed_out": false,
   "_shards": {
      "total": 5,
      "successful": 5,
      "failed": 0
   },
   "hits": {
      "total": 1,
      "max_score": 8.156567,
      "hits": [
         {
            "_index": "zoek",
            "_type": "geo",
            "_id": "4533",
            "_score": 8.156567,
            "_source": {
               "geonameid": "2748193",
               "name": "Rhee",
               "locatie": [
                  53.0325,
                  6.56667
               ],
               "country": "NL"
            }
         }
      ]
   }
}

- >现在我想查询半径15公里范围内的所有地方“rhee” (例如)

GET /zoek/geo/_search
{
    "filtered" : {
        "query" : {
            "match": { "name": "rhee" }
        },
        "filter" : {
            "geo_distance" : {
                "distance" : "15km",
                "locatie" : [ 53.0325, 6.56667 ]
                }
            }
        }
    }
}

引发以下异常:

SearchPhaseExecutionException [无法执行阶段[查询],所有分片都失败; shardFailures

解析失败[没有解析元素[filtered]]]

此外,此查询:

get /zoek/geo/_search
{
  "query": {
    "filtered": {
      "filter": {
              "geo_distance": {
                "distance": "5km",
                "locatie": [ 53.0325, 6.56667 ]
                }
              }
      }
    }
  }
}

返回所有字段,而不是5公里距离记录。

有什么建议吗?

和平,

的Digi

1 个答案:

答案 0 :(得分:0)

更改此查询

{
    "filtered" : {
        "query" : {
            "match" : {
                "name" : "rhee"
            }
        },
        "filter" : {
            "geo_distance" : {
                "distance" : "15km",
                "locatie" : [53.0325, 6.56667]
            }
        }
    }
}

{
    "query" : {
        "filtered" : {
            "query" : {
                "match" : {
                    "name" : "rhee"
                }
            },
            "filter" : {
                "geo_distance" : {
                    "distance" : "15km",
                    "locatie" : [53.0325, 6.56667]
                }
            }
        }
    }
}

query失踪。