Mat*_*att 2 geolocation elasticsearch geopoints
更新我还更新了映射以包含引脚,如示例所示.此外,这是一个临时实例,其中包含一些数据:https://21991e47cdc7caa8000.qbox.io/profiles/lead/_search
我遵循了ElasticSearch的指示.使用此请求:
$.ajax({
url: 'https://21991e47cdc7caa8000.qbox.io/profiles/lead/_search',
method: 'GET',
data: {
sort: [{
_geo_distance: {
"pin.location": [49.8998, -97.1375],
order: "asc",
unit: "km"
}
}]
},
success: function(response) {
console.log(response);
}
});
Run Code Online (Sandbox Code Playgroud)
不distance按计算返回或按距离排序.我也试过用"location".
这是我的映射:https://21991e47cdc7caa8000.qbox.io/profiles/lead/_mapping
有任何想法吗?
我设法让它工作,请看到区别,
我在查询之前将数据转换为json,并添加了一些配置(将dataType更改为json,并将请求类型更改为POST,因为我们知道GET请求通常没有正文,只有POST请求.
var request = {
sort: [{
_geo_distance: {
"pin.location": [
49.8998, -97.1375],
order: "asc",
unit: "km"
}
}]
};
$.ajax({
url: 'https://21991e47cdc7caa8000.qbox.io/profiles/lead/_search',
type: 'POST',
crossDomain: true,
dataType: 'json',
data: JSON.stringify(request),
success: function (response) {
console.log(JSON.stringify(response));
}
});
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助.
我已经测试过了,它也适合你.
| 归档时间: |
|
| 查看次数: |
2131 次 |
| 最近记录: |