【发布时间】:2014-12-13 07:53:14
【问题描述】:
所以我正在试验 ElasticSearch,这就是我所做的。
1) 在我的索引上添加了一个名为“test”的 geo_point 映射
curl -XPOST localhost:9200/test -d '{
"mappings" : {
"type1" : {
"_source" : { "enabled" : false },
"properties" : {
"location" : { "type" : "geo_point", "index" : "not_analyzed" }
}
}
}
}'
2) 为测试中的文档建立索引:
curl -XPUT 'localhost:9200/test/type1/1?pretty' -d '{
"location" : {
"lat" : 74,
"lon" : 90
}
}'
3) 然后通过地理位置过滤器编写一个查询,如下所示:
curl -XPOST 'localhost:9200/test2/_search?pretty' -d '{
"filtered" : {
"query" : {
"match_all" : {}
},
"filter" : {
"geo_distance" : {
"distance" : "200km",
"location" : {
"lat" : 40,
"lon" : -70
}
}
}
}
}'
为此我得到:
"error" : "SearchPhaseExecutionException[未能执行阶段 [查询],所有分片失败;分片失败 {[QpGEHtdcReeYmt8X2tG26g][test2][0]: RemoteTransportException[[Jester][inet[/10.58.91.21:9301]][search/phase/query]]; 嵌套:SearchParseException[[test2][0]: from[-1],size[-1]: Parse 失败[无法解析源[na]]];嵌套: ElasticsearchParseException [无法从 org.elasticsearch.common.bytes.ChannelBufferBytesReference@60d8bc76];
【问题讨论】:
-
你能在没有地理信息的情况下运行简单的查询吗?
-
是的,前两个成功了。但第三个失败了。