Geo Bounding Box Query

一种查询,允许根据一个点位置过滤命中,使用一个边界框。假设以下索引文档:

PUT /my_locations
{
"mappings": {
"_doc": {
"properties": {
"pin": {
"properties": {
"location": {
"type": "geo_point"
}
}
}
}
}
}
} PUT /my_locations/_doc/1
{
"pin" : {
"location" : {
"lat" : 40.12,
"lon" : -71.34
}
}
}

然后,可以使用geo_bounding_box过滤器来执行以下简单查询:

GET /_search
{
"query": {
"bool" : {
"must" : {
"match_all" : {}
},
"filter" : {
"geo_bounding_box" : {
"pin.location" : {
"top_left" : {
"lat" : 40.73,
"lon" : -74.1
},
"bottom_right" : {
"lat" : 40.01,
"lon" : -71.12
}
}
}
}
}
}
}

查询参数

_name:可选名称字段来识别过滤器

validation_method:设置为忽略不正确的纬度或经度的地质点,设置为强制也试图推断正确的纬度或经度。(默认是严格)

type:设置为索引或内存,以定义该过滤器是否将在内存中执行或索引。有关进一步详细信息,请参阅下面的类型,默认是内存。

可以被接受的格式

同样地,geo_point类型可以接受地理点的不同表示,过滤器也可以接受它:

Lat Lon 作为属性

GET /_search
{
"query": {
"bool" : {
"must" : {
"match_all" : {}
},
"filter" : {
"geo_bounding_box" : {
"pin.location" : {
"top_left" : {
"lat" : 40.73,
"lon" : -74.1
},
"bottom_right" : {
"lat" : 40.01,
"lon" : -71.12
}
}
}
}
}
}
}

Lat Lon 作为数组

GET /_search
{
"query": {
"bool" : {
"must" : {
"match_all" : {}
},
"filter" : {
"geo_bounding_box" : {
"pin.location" : {
"top_left" : [-74.1, 40.73],
"bottom_right" : [-71.12, 40.01]
}
}
}
}
}
}

Lat Lon 作为字符串

GET /_search
{
"query": {
"bool": {
"must": {
"match_all": {}
},
"filter": {
"geo_bounding_box": {
"pin.location": {
"top_left": "40.73, -74.1",
"bottom_right": "40.01, -71.12"
}
}
}
}
}
}

边界框作为著名文本(WKT)

GET /_search
{
"query": {
"bool" : {
"must" : {
"match_all" : {}
},
"filter" : {
"geo_bounding_box" : {
"pin.location" : {
"wkt" : "BBOX (-74.1, -71.12, 40.73, 40.01)"
}
}
}
}
}
}

Geohash

GET /_search
{
"query": {
"bool" : {
"must" : {
"match_all" : {}
},
"filter" : {
"geo_bounding_box" : {
"pin.location" : {
"top_left" : "dr5r9ydj2y73",
"bottom_right" : "drj7teegpus6"
}
}
}
}
}
}

顶角

边界框的顶点可以由上左和右下,也可以由上右和下左参数设置。更多的是支持左、右、上右和左下的名称。不要设置成对的值,而是可以使用简单的名称顶部、左边、底部和右边来分别设置这些值。

GET /_search
{
"query": {
"bool" : {
"must" : {
"match_all" : {}
},
"filter" : {
"geo_bounding_box" : {
"pin.location" : {
"top" : 40.73,
"left" : -74.1,
"bottom" : 40.01,
"right" : -71.12
}
}
}
}
}
}

geo_point type

过滤器要求在相关字段上设置geo_point类型。

每个索引文档多个坐标

这个过滤器可以处理每个文档的多个位置/点。一旦一个位置/点与过滤器匹配,文档就会被包含在过滤器中

类型

默认情况下,边界框执行的类型被设置为内存,这意味着在内存检查中,如果doc落在边界框范围内。在某些情况下,一个索引选项将执行得更快(但是注意,在这种情况下,geopoint类型必须有lat和lon索引)。注意,当使用索引选项时,不支持每个文档字段的多位置。这是一个例子:

GET /_search
{
"query": {
"bool" : {
"must" : {
"match_all" : {}
},
"filter" : {
"geo_bounding_box" : {
"pin.location" : {
"top_left" : {
"lat" : 40.73,
"lon" : -74.1
},
"bottom_right" : {
"lat" : 40.10,
"lon" : -71.12
}
},
"type" : "indexed"
}
}
}
}
}

忽略地图上未标明的

当把ignore_unmapped参数设置为true时,将忽略一个未映射的字段,并且不会匹配该查询的任何文档。这在查询可能有不同映射的多个索引时非常有用。当设置为false(默认值)时,如果字段没有映射,查询将抛出异常。

笔记精度

地球仪的精度是有限的,在索引时间内总是被四舍五入。在查询期间,边界框的上边界被四舍五入,而较低的边界被四舍五入。结果是,由于舍入误差,在下限(边界框的底部和左边缘)上的点可能不会进入到边界框中。与此同时,即使它们位于边缘之外,也可以通过查询选择上界(顶部和右边缘)。在纬度上,舍入误差小于4。20e-8度,经度小于8。39-8度,即使在赤道处也会出现小于1厘米的误差。

elasticsearch Geo Bounding Box Query的更多相关文章

  1. Elasticsearch(GEO)空间检索查询

    Elasticsearch(GEO)空间检索查询python版本 1.Elasticsearch ES的强大就不用多说了,当你安装上插件,搭建好集群,你就拥有了一个搜索系统. 当然,ES的集群优化和查 ...

  2. 基于百度地图SDK和Elasticsearch GEO查询的地理围栏分析系统(1)

    本文描述了一个系统,功能是评价和抽象地理围栏(Geo-fencing),以及监控和分析核心地理围栏中业务的表现. 技术栈:Spring-JQuery-百度地图WEB SDK 存储:Hive-Elast ...

  3. Elasticsearch(GEO)数据写入和空间检索

    Elasticsearch简介 什么是 Elasticsearch? Elasticsearch 是一个开源的分布式 RESTful搜索和分析引擎,能够解决越来越多不同的应用场景. 本文内容 本文主要 ...

  4. elasticsearch的javaAPI之query

    elasticsearch的javaAPI之query API the Search API同意运行一个搜索查询,返回一个与查询匹配的结果(hits). 它能够在跨一个或多个index上运行, 或者一 ...

  5. 3D空间中的AABB(轴向平行包围盒, Aixe align bounding box)的求法

    引言 在前面的一篇文章中讲述了怎样通过模型的顶点来求的模型的包围球,而且还讲述了基本包围体除了包围球之外,还有AABB包围盒.在这一章,将讲述怎样依据模型的坐标求得它的AABB盒. 表示方法 AABB ...

  6. Latex 中插入图片no bounding box 解决方案

    在windows下,用latex插入格式为jpg,png等图片会出现no bounding box 的编译错误,此时有两个解决办法: 1.将图片转换为eps格式的图片 \usepackage{grap ...

  7. bounding box的简单理解

    1. 小吐槽 OverFeat是我看的第一篇深度学习目标检测paper,因为它是第一次用深度学习来做定位.目标检测问题.可是,很难懂...那个bounding box写得也太简单了吧.虽然,很努力地想 ...

  8. 论文阅读笔记四十七:Generalized Intersection over Union: A Metric and A Loss for Bounding Box Regression(CVPR2019)

    论文原址:https://arxiv.org/pdf/1902.09630.pdf github:https://github.com/generalized-iou 摘要 在目标检测的评测体系中,I ...

  9. 第二十六节,滑动窗口和 Bounding Box 预测

    上节,我们学习了如何通过卷积网络实现滑动窗口对象检测算法,但效率很低.这节我们讲讲如何在卷积层上应用这个算法. 为了构建滑动窗口的卷积应用,首先要知道如何把神经网络的全连接层转化成卷积层.我们先讲解这 ...

随机推荐

  1. Codeforces 600A. Extract Numbers 模拟

    A. Extract Numbers time limit per test: 2 seconds memory limit per test: 256 megabytes input: standa ...

  2. 前后台交互(打开前端页面,不传递任何数据,发送ajax请求)

    1.打开前端,不传递任何数据 <script src="./jquery.min.js"></script> <script> $(docume ...

  3. SVN中检出 和 导出 的区别

    SVN中检出 和 导出 的区别:检出得到的文件夹中,是受SVN客户端控制的,对其进行文件或文件夹的增删改操作都会被SVN客户端识别出来,对其可以进行update.commit操作.其中含有.svn隐藏 ...

  4. 2018.09.22 牧场的安排(状压dp)

    描述 农民 John 购买了一处肥沃的矩形牧场,分成M*N(1 <= M <= 12; 1 <= N <= 12)个 格子.他想在那里的一些格子中种植美味的玉米.遗憾的是,有些 ...

  5. 2018.07.22 codeforces750E(线段树维护状态转移)

    传送门 给出一个数字字串,给出若干个询问,询问在字串的一段区间保证出现2017" role="presentation" style="position: re ...

  6. (线段树 区间查询)The Water Problem -- hdu -- 5443 (2015 ACM/ICPC Asia Regional Changchun Online)

    链接: http://acm.hdu.edu.cn/showproblem.php?pid=5443 The Water Problem Time Limit: 1500/1000 MS (Java/ ...

  7. (连通图)Network--POJ--3694

    链接: http://poj.org/problem?id=3694 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=82833#probl ...

  8. Docker load与Docker import

    docker load与docker import   首先,想要清楚的了解docker load与docker import命令的区别,就必须了解镜像与容器的区别: 镜像:用来启动容器的只读模板,是 ...

  9. sklearn 中fit_tansform 与 transform的区别

    https://blog.csdn.net/anecdotegyb/article/details/74857055 先fit_transform 后transform,不然会报错.

  10. MVC-1.1 BundleConfig-ScriptBundle

    App_Start中的BudleCnfig.cs中 bundles.Add(new ScriptBundle("~/bundles/jquery").Include( " ...