Elasticsearch 高手之路
  • Introduction
  • First Chapter
  • 1.ElasticSearch 5.x 安装
    • 1.1.Window 环境
    • 1.2.Linux 环境
  • 2.基础学前班
  • 3.基础
    • 3.1.配置文件
    • 3.2.Mapping
      • 3.2.1.字段的数据类型
        • 3.2.1.1.核心数据类型
        • 3.2.1.2.复合数据类型
        • 3.2.1.3.Geo地理数据类型
        • 3.2.1.4.特定数据类型
      • 3.2.2.Meta-Fields(元字段)
        • _index,_uid,_type,_id 元字段
        • _source,_size 元字段
        • _all, _field_names元字段
        • _parent,_routing 元字段
        • _meta 元字段
      • 3.2.3.Mapping parameters(映射参数)
        • analyzer(分析器)
        • normalizer(归一化)
        • boost(提升)权重
        • Coerce(强制类型转换)
        • copy_to(合并参数)
        • doc_values(文档值)
        • dynamic(动态设置)
        • enabled(开启字段)
        • fielddata(字段数据)
        • format (日期格式)
        • ignore_above(忽略超越限制的字段)
        • ignore_malformed(忽略格式不对的数据)
        • include_in_all(_all 查询包含字段)
        • index_options(索引设置)
        • index (索引)
        • fields(字段)
        • norms (标准信息)
        • null_value(空值)
        • position_increment_gap(短语位置间隙)
        • properties (属性)
        • search_analyzer (搜索分析器)
        • similarity (相似度模型)
        • store(存储)
        • term_vectors(词根信息)
      • 3.2.4.Dynamic Mapping(动态映射)
        • _default_ mapping(mapping中的_default_)
        • Dynamic field mapping(动态字段映射)
        • Dynamic templates(动态模板)
        • Override default template(覆盖默认模板)
    • 3.3. Analysis(分析)
      • 3.3.1.Anatomy of an analyzer(分析器的分析)
      • 3.3.2.Testing analyzers(测试分析器)
      • 3.3.3.Analyzers(分析器)
        • Configuring built-in analyzers(配置内置分析器)
        • Standard Analyzer(标准分析器)
        • Simple Analyzer(简单分析器)
        • Whitespace Analyzer(空格分析器)
        • Stop Analyzer(停止词分词器)
        • Keyword Analyzer(关键词分析器)
        • Pattern Analyzer(模式分析器)
        • Language Analyzers(语言分析器)
        • Fingerprint Analyzer(指纹分析器)
        • Custom Analyzer(自定义分析器)
      • 3.3.4. Tokenizers(分词器)
        • Standard Tokenizer(标准分词器)
        • Letter Tokenizer
        • Lowercase Tokenizer (小写分词器)
        • Whitespace Tokenizerr (空格分词器)
        • UAX URL Email Tokenizer
        • Classic Tokenizer
        • Thai Tokenizer(泰语分词器)
        • NGram Tokenizer
        • Edge NGram Tokenizer
        • Keyword Tokenizer(关键词分词器)
        • Pattern Tokenizer(模式分词器)
        • Path Hierarchy Tokenizer(路径层次分词器)
      • 3.3.5.Token Filters(词语过滤器)
      • 3.3.5.补充1:Token Filters(词语过滤器)
      • 3.3.5.补充2:Token Filters(词语过滤器)
      • 3.3.6.Character Filters(字符过滤器)
        • HTML Strip Character Filter(HTML标签过滤)
        • Mapping Character Filter(字符替换映射)
        • Pattern Replace Character Filter(正则替换字符)
    • 3.4. APIs
      • 3.4.1.索引 APIs (Indices APIs)
        • 创建/删除/获取->索引
        • 启动关闭/缩小/滚动->索引
        • 提交/获取/获取字段->映射
        • 索引->别名/是否存在/类型存在
        • 更新索引/获取->设置(未完成)
        • 分析器、索引模板(未完成)
        • Shadow replica indices 卷影副本索引
        • 索引->统计信息/段
        • 索引->恢复/分片存储
        • 清理缓存/刷新/同步刷新
        • 重新加载/强制合并
      • 3.4.2.文档 APIs (Document APIs)
        • 读写文档(Reading and Writing documents)
        • 索引文档 API
        • 获取/批量获取->文档
        • 删除/根据查询API删除
        • 更新/根据查询API更新
        • Bulk API(批量操作)
        • Reindex API(复制索引)
        • Term Vectors(词条向量)/Multi termvectors API
        • ?refresh
      • 3.4.3.搜索 APIs (Search APIs)
        • Search / URI Search
        • Request Body Search(未完成)
          • Query / From / Size
          • Sort / Source filtering
          • Fields / Script Fields / Doc value Fields
          • Post filter
          • Highlighting
          • Rescoring / Search Type
          • Scroll
          • Preference / Explain
          • Version / Index Boost
          • min_score / Named Queries
          • Inner hits / Search After
          • Field Collapsing 字段折叠
        • Search 模板/Multi Search 模板
        • Search Shards API
        • Suggesters
          • Term suggester
          • Phrase Suggester
          • Completion Suggester
          • Context Suggester
          • 返回suggester的类型
        • Multi Search API
        • Count API
        • Validate API
        • Explain API
        • Profile API
          • Profiling Queries
          • Profiling Aggregations
          • Profiling Considerations
        • Percolator / Field stats API
        • Field Capabilities API
    • 3.5.Query DSL(DSL方式查询)
      • 3.5.1.查询和过滤上下文
      • 3.5.2.Match All 查询
      • 3.5.3.全文搜索(Full Text Search)
        • 匹配查询(Match Query)
        • 短语匹配查询(Match Phrase Query)
        • 短语前缀匹配查询(Match Phrase Prefix Query)
        • 多字段查询(Multi Match Query)
        • 常用术语查询(Common Terms Query)
        • (Query String Query) 未完成
      • 3.5.4.Term级别查询(Term level queries)
        • Term 查询
        • Terms 查询
        • Range 查询(范围查询)
        • Exists 查询(非空值查询)
        • Prefix 查询(前缀查询)
        • Wildcard 查询(通配符查询)
        • Regexp 查询(正则表达式查询)
        • Fuzzy 查询(模糊查询)
        • Type Query(类型查询)
        • Ids Query(ID 查询)
      • 3.5.5.复合查询(Compound queries)
        • Constant Score 查询
        • Bool 查询
        • Dis Max 查询
        • Function Score 查询
        • Boosting 查询
        • Indices 查询
      • 3.5.6.Joining 查询(连接查询)
        • Nested Query(嵌套查询)
        • Has Child Query
        • Has Parent Query
        • Parent Id Query
      • 3.5.7.地理位置查询 (Geo queries)
        • GeoShape Query(地理形状查询)
        • Geo Bounding Box Query(地理边框查询)
        • Geo Distance Query(地理距离查询)
        • Geo Distance Range Query(地理距离范围查询)
        • Geo Polygon Query(地理多边形查询)
      • 3.5.8.专业查询(Specialized queries)
      • 3.5.9.Span 查询
        • Span Term 查询
        • Span Multi Term 查询
        • Span First 查询
        • Span Near 查询
        • Span Or 查询
        • Span Not 查询
        • Span Containing 查询
        • Span Within 查询
        • Span Field Masking 查询
    • 3.6.Aggregations(聚合分析)
      • 3.6.1.量度聚合(Metric Aggregations)
        • 平均值聚合(Avg Aggregation)
        • 基数聚合(Cardinality Aggregation)
        • 扩展统计聚合( Extended Stats Aggregation)
        • 地理边界聚合(Geo Bounds Aggregation)
        • 地理重心聚合(Geo Centroid Aggregation)
        • 最大值聚合(Max Aggregation)
        • 最小值聚合(Min Aggregation)
        • Percentiles Aggregation
        • Percentile Ranks Aggregation
        • Scripted Metric Aggregation
        • Stats Aggregation
        • 总和聚合(Sum Aggregation)
        • Top hits Aggregation
        • Value Count Aggregation
      • 3.6.2.桶聚合(Bucket Aggregations)
        • 邻接矩阵聚合(Adjacency Matrix Aggregation)
        • Children Aggregation
        • 日期直方图聚合(Date Histogram Aggregation)
        • 日期范围聚合(Date Range Aggregation)
        • 多元化的采样器聚集(Diversified Sampler Aggregation)
        • 过滤器聚合(Filter Aggregation)
        • 多过滤器聚合(Filters Aggregation)
        • 地理距离聚合(Geo Distance Aggregation)
        • GeoHash网格聚合(GeoHash grid Aggregation)
        • 全局聚合(Global Aggregation)
        • 直方图聚合(Histogram Aggregation)
        • IP范围聚合(IP Range Aggregation)
        • 丢失字段聚合(Missing Aggregation)
        • 嵌套聚合(Nested Aggregation)
        • 范围聚合(Range Aggregation)
        • Reverse nested Aggregation
        • 采样聚合(Sampler Aggregation)
        • Significant Terms Aggregation
      • 3.6.3.管道聚合(Pipeline Aggregations)
        • 平均值桶聚合( Avg Bucket Aggregation)
        • 导数聚合(Derivative Aggregation)
        • 最大值桶聚合(Max Bucket Aggregation)
        • 最小值桶聚合(Min Bucket Aggregation)
        • 总和桶聚合(Sum Bucket Aggregation)
        • 统计桶聚合(Stats Bucket Aggregation)
        • 扩展信息桶聚合(Extended Stats Bucket Aggregation)
        • 百分数桶聚合(Percentiles Bucket Aggregation)
        • Moving Average Aggregation
        • 累积汇总聚合(Cumulative Sum Aggregation)
        • 桶脚本聚合(Bucket Script Aggregation)
        • 桶选择器聚合(Bucket Selector Aggregation)
        • 串行差异聚合(Serial Differencing Aggregation)
      • 3.6.4.矩阵聚合(Matrix Aggregations)
        • 矩阵统计(Matrix Stats)
      • 3.6.5.缓存频繁聚合(Caching heavy aggregations)
      • 3.6.6.仅返回需要聚合的结果(Returning only aggregation results)
      • 3.6.7.聚合元数据(Aggregation Metadata)
      • 3.6.8.返回聚合的类型(Returning the type of the aggregation)
    • Glossary of terms (词汇表)
    • 未完成的任务
  • 4.基础补充总结
    • 3.2.Mapping
    • 3.3.分析器与定义自己的分析器(Analyzer)
  • 原理
  • 实战
    • 结构化搜索
    • 聚合分析
    • 数据建模
    • 应用场景
  • PHP API
    • 安装与快速入门
    • 配置
    • 实战
  • 资料
  • 笔记
    • 1.x 升级 2.x
Powered by GitBook
On this page
  • Geo-point 地理坐标型
  • Geo_point 字段参数
  • 使用geo-points脚本
  • Geo-Shape 地理图形型
  • Mapping 选项
  • Prefix trees(前缀树)
  • Input Structure

Was this helpful?

  1. 3.基础
  2. 3.2.Mapping
  3. 3.2.1.字段的数据类型

3.2.1.3.Geo地理数据类型

分类

数据类型

Geo-point 地理坐标型

geo_point数据类型:描述纬度/经度坐标

Geo-Shape 地理图形型

geo_shape数据类型:描述多边形等复杂形状

Geo-point 地理坐标型

geo-points类型字段使用横纵坐标经伟度,使用方法

  • 1.在边界框内或多边形内,找中心点和离中心点的一定距离的点。

  • 2.从地理位置或从中心点的距离组成搜索文本

  • 3.根据位置距离给搜索文本评分

  • 4.根据得分进行搜索文本排序

有四种方法可以指定地理点,如下所示

PUT my_index
{
  "mappings": {
    "my_type": {
      "properties": {
        "location": {
          "type": "geo_point"
        }
      }
    }
  }
}

PUT my_index/my_type/1
{
  "text": "Geo-point as an object",
  "location": {        # 1
    "lat": 41.12,
    "lon": -71.34
  }
}

PUT my_index/my_type/2
{
  "text": "Geo-point as a string",
  "location": "41.12,-71.34"          # 2
}

PUT my_index/my_type/3
{
  "text": "Geo-point as a geohash",
  "location": "drm3btev3e86"          # 3
}

PUT my_index/my_type/4
{
  "text": "Geo-point as an array",
  "location": [ -71.34, 41.12 ]      # 4
}

GET my_index/_search
{
  "query": {
    "geo_bounding_box": {          # 5
      "location": {
        "top_left": {
          "lat": 42,
          "lon": -72
        },
        "bottom_right": {
          "lat": 40,
          "lon": -74
        }
      }
    }
  }
}

1

Geo-point 可以用对象表示描述:有横坐标和纵坐标两点.

2

Geo-point 可以带有“,”间隔符的字符串表示描述.

3

Geo-point 可以用geohash哈希来表示描述.

4

Geo-point 可以用这样的数组格式: [ lon, lat]来表示描

5

可以用查询边界框里面的点来表示描述.

注意:表示为数组或字符串的地理点

请注意用string类型描述geo-points格式,和数组类型描述geo-points格式

正好,模纵坐标可以放string类型或数组类型,但是数组是可以转换成JOSN格式

Geo_point 字段参数

下面是Geo_point 字段参数

ignore_malformed

如果true,异常Geo_point数据被忽略,false,将会抛出异常,不接受执行整个搜索文本(默认为false)

使用geo-points脚本

使用脚本查询一个地理点的数据时,该值作为一个GeoPoint对象返回,它允许访问。LAT和LON。值分别为:

def geopoint = doc['location'].value;
def lat      = geopoint.lat;
def lon      = geopoint.lon;

对于性能的原因,请直接访问搜索文本的经度值:

lat      = doc['location'].lat;
lon      = doc['location'].lon;

Geo-Shape 地理图形型

Geo_shape数据类型有利于有助于索引和搜索任意地理形状,如:矩形和多边形。我们这样使用它:数据索引或执行点状数据查询

你能使用geo_shape 查询引擎,查询搜索文本。

Mapping 选项

Geo_shape mapping 绘制geo_shape 类型的 geo_json 几何对象

Option

Description

Default

tree

使用PrefixTree :geohash类型的GeohashPrefixTree 或quadtree 类型的QuadPrefixTree

geohash

precision

这个参数可以用来代替tree_levels设置为适当的值tree_levels参数。该值指定所需的精度,Elasticsearch将计算出最佳有价值的精度tree_levels。值应该是一个数字,然后是可选的距离单位。有效距离的单位包括:英寸,寸码,米,公里,米,厘米,毫米

meters

tree_levels

这一点被prefixTree应用最多。这可以用来控制形状表示的精度,因些需要索引很多个词,选择prefixtree默认值,由于此参数要求对底层实现有一定程度的理解,因此用户可以使用精度参数。然而,Elasticsearch只用tree_levels参数,这是通过映射的API,即使你使用精度的参数返回。

50m

strategy

策略参数定义了如何在索引和搜索时间中表示形状的方法。它也影响的能力提供建议让Elasticsearch自动设置这个参数。有两种策略可供选择:递归和术语。长期的战略支撑点类型(的points_only参数将被自动设置为true),递归策略支持所有的形状类型。(重要:参见前缀树获取更详细的信息)

recursive

distance_error_pct

作为一个暗示,PrefixTree如何精确的应。默认值为0.025(2.5%),最大支持值为0.5。性能备注:这个值将默认为0如果精度或tree_level定义明确定义。这保证映射中定义的级别的空间精度。这会导致高分辨率的内存使用率低(例如,100米的大图形和0.001错误)。提高索引性能(在查询精度成本)明确随着合理的distance_error_pct tree_level或精度,指出大的形状将有更大的误报。

0.025

orientation

可以定义如何解释/ multipolygons多边形顶点顺序。这个参数定义了两个坐标系统规则(右手或左手)中的一个,每个规则可以用三种不同的方式指定。1。右手定则:右,逆时针逆时针,2。左手定则:左,顺时针,顺时针。默认方向(逆时针)符合定义的顶点按逆时针顺序与外环内环OGC标准(S)的顶点(孔)按顺时针方向的。在geo_shape映射这个参数设置显式设置为一个geo_shape场坐标列表顶点顺序但可在每个GeoJSON文件重写。

ccw

points_only

设置此选项为true(默认为false)配置点的geo_shape字段类型形状(注:多点尚未支持)。这优化为Geohash和四叉树索引和搜索性能的时候它是已知的唯一的点会被索引。目前geo_shape查询无法执行的geo_point字段类型。这个选项,架起了一座桥梁,通过提高在geo_shape场点的表现让geo_shape查询优化一点场。

false

Prefix trees(前缀树)

有效的指数代表的形状,形状转换成一系列的哈希值代表方格(通常被称为“栅格”)使用一个prefixtree实现。树的概念来自这样一个事实:prefixtree采用多重网格层,每一个增加的精度水平代表地图。这可以看作是在更高的缩放级别上增加地图或图像的细节级别。

提供了多个prefixtree实现

  • geohashprefixtree使用geohashes方格。geohashes是Base32编码字符串的纬度和经度的比特交织。所以哈希越长,它就越精确。每个字符添加到Geohash代表另一个树的水平和增加了5位精度的Geohash。一个Geohash表示一个矩形的面积,32个矩形。在Elasticsearch级别的最大量为24。

  • quadprefixtree -使用一个四叉树的方格。类似Geohash,四叉树交错的经度和纬度产生的哈希位有点集。四叉树中的树级别代表这个位集中的2位,每个坐标的一位。在Elasticsearch的四叉树级别的最大量为50。

Spatial strategies

prefixtree的实现依赖于一种分解提供的形状spatialstrategy(S)为近似方格。每种策略都回答以下问题:

  1. 什么类型的形状可以被索引?

  2. 可以使用什么类型的查询操作或形状?

  3. 它支持每个字段超过一个形状吗?

提供了以下策略实现(具有相应的功能):

Strategy

Supported Shapes

Supported Queries

Multiple Shapes

recursive

INTERSECTS, DISJOINT, WITHIN, CONTAINS

Yes

term

INTERSECTS

Yes

Accuracy

geo_shape不提供100%的准确度,取决于它是如何配置它可能会返回一些假阳性或假阴性的某些查询。为了解决这个问题,这是选择的tree_levels参数调整的预期因此适当的重要价值。例如,一个点可以在一个特定的网格单元的边界,因此可能不匹配的查询匹配的细胞在它旁边 - 虽然外形非常接近的点。

例子:

PUT /example
{
    "mappings": {
        "doc": {
            "properties": {
                "location": {
                    "type": "geo_shape",
                    "tree": "quadtree",
                    "precision": "1m"
                }
            }
        }
    }
}

这个映射图位置字段中使用quad_tree实现和精度1m geo_shape型。Elasticsearch转化为tree_levels设置26。

关于系统性能方面的问题

Elasticsearch使用路径的前缀树的索引和查询。级别越高(因而精度越高)生成的代码越多。当然,计算这些代码,将它们保存在内存中,并将它们存储在磁盘上都是有代价的。尤其是树级别较高的情况下,即使只有少量的数据,索引也可能变得非常大。此外,功能的大小也很重要。大而复杂的多边形可以在较高的树级别占用大量空间。哪个设置正确取决于用例。一般情况下,索引精度和查询性能都会降低准确性。

为实现在Elasticsearch默认索引的大小和在赤道精密50M的合理水平之间的一种折衷。这使得索引数以千万计的形状,而不会过度膨胀的结果指数太大,相对于输入大小。

Input Structure

GeoJSON格式的是用来表示形状输入如下:

GeoJSON Type

Elasticsearch Type

Description

Point

point

单一地理坐标

LineString

linestring

给定两个或多个点的任意线。

Polygon

polygon

一个封闭的多边形的第一个和最后一个点必须匹配,因此需要n + 1个顶点创建一个N边多边形和至少4个顶点。

MultiPoint

multipoint

An array of unconnected, but likely related points.

MultiLineString

multilinestring

An array of separate linestrings.

MultiPolygon

multipolygon

一组单独的多边形。

GeometryCollection

geometrycollection

A GeoJSON shape similar to the multi* shapes except that multiple types can coexist (e.g., a Point and a LineString).

N/A

envelope

A bounding rectangle, or envelope, specified by specifying only the top left and bottom right points.

N/A

circle

A circle specified by a center point and radius with units, which default to METERS.

对于所有类型,都需要内部类型和坐标字段。

在GeoJSON,因此Elasticsearch,正确的坐标为经度、纬度(x,y)的坐标数组。这不同于许多地理空间API(例如,谷歌地图),它们通常使用纬度、经度(y、x)。

Point

一个点是一个单一的地理坐标位置,如建筑物或当前位置通过智能手机的地理定位API了。

POST /example/doc
{
    "location" : {
        "type" : "point",
        "coordinates" : [-77.03653, 38.897676]
    }
}

LineString

由两个或两个以上的位置数组定义的线。通过指定两点的线表示一条直线。指定多于两个点会创建任意路径。

POST /example/doc
{
    "location" : {
        "type" : "linestring",
        "coordinates" : [[-77.03653, 38.897676], [-77.009051, 38.889939]]
    }
}

上面的线就画一直线,从白宫到美国的首都大厦。

Polygon

多边形是由一个点的列表定义的。每个(外部)列表中的第一个和最后一个点必须是相同的(多边形必须是闭合的)。

POST /example/doc
{
    "location" : {
        "type" : "polygon",
        "coordinates" : [
            [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ]
        ]
    }
}

第一个数组代表多边形的外边界,其他数组表示内部形状(”holes”)

POST /example/doc
{
    "location" : {
        "type" : "polygon",
        "coordinates" : [
            [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ],
            [ [100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2] ]
        ]
    }
}

重要注意事项:

GeoJSON并不要求如此明确的多边形顶点在日界线内,顶点的特定顺序是可能的。为了减轻模糊开放地理空间联盟(OGC)的简单功能接入规范定义了下面的顶点顺序

  • 外圈-逆时针方向

  • 内圈-顺时针方向

多边形不越过日界线,顶点顺序将不在Elasticsearch。多边形做过日界线,Elasticsearch需要顶点顺序符合OGC规范。否则,可能会创建一个意外的多边形,并返回意外的查询/过滤结果。

下面提供了一个不明确多边形的示例。Elasticsearch将OGC标准消除产生一个多边形,越过日界线歧义。

POST /example/doc
{
    "location" : {
        "type" : "polygon",
        "coordinates" : [
            [ [-177.0, 10.0], [176.0, 15.0], [172.0, 0.0], [176.0, -15.0], [-177.0, -10.0], [-177.0, 10.0] ],
            [ [178.2, 8.2], [-178.8, 8.2], [-180.8, -8.8], [178.2, 8.8] ]
        ]
    }
}

一个定位参数可以定义设置geo_shape映射时(参见“映射optionsedit”)。这将定义的映射geo_shape场坐标列表顶点顺序。它也可以覆盖在每个文档上。下面是覆盖文档方向的示例:

POST /example/doc
{
    "location" : {
        "type" : "polygon",
        "orientation" : "clockwise",
        "coordinates" : [
            [ [-177.0, 10.0], [176.0, 15.0], [172.0, 0.0], [176.0, -15.0], [-177.0, -10.0], [-177.0, 10.0] ],
            [ [178.2, 8.2], [-178.8, 8.2], [-180.8, -8.8], [178.2, 8.8] ]
        ]
    }
}

MultiPoint

GeoJSON点列表。

POST /example/doc
{
    "location" : {
        "type" : "multipoint",
        "coordinates" : [
            [102.0, 2.0], [103.0, 2.0]
        ]
    }
}

MultiLineString

GeoJSON线要素列表

POST /example/doc
{
    "location" : {
        "type" : "multilinestring",
        "coordinates" : [
            [ [102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0] ],
            [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0] ],
            [ [100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8] ]
        ]
    }
}

MultiPolygon

GeoJSON多边形列表。

POST /example/doc
{
    "location" : {
        "type" : "multipolygon",
        "coordinates" : [
            [ [[102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0], [102.0, 2.0]] ],
            [ [[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]],
              [[100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2]] ]
        ]
    }
}

Geometry Collection

GeoJSON几何对象的集合。

POST /example/doc
{
    "location" : {
        "type": "geometrycollection",
        "geometries": [
            {
                "type": "point",
                "coordinates": [100.0, 0.0]
            },
            {
                "type": "linestring",
                "coordinates": [ [101.0, 0.0], [102.0, 1.0] ]
            }
        ]
    }
}

Envelope

Elasticsearch支持一个信封式的,包括对形状代表一个矩形的左上角和右下角点的坐标:

POST /example/doc
{
    "location" : {
        "type" : "envelope",
        "coordinates" : [ [-45.0, 45.0], [45.0, -45.0] ]
    }
}

Circle

Elasticsearch支持圆式,它由一个中心点和半径:

POST /example/doc
{
    "location" : {
        "type" : "circle",
        "coordinates" : [-45.0, 45.0],
        "radius" : "100m"
    }
}

注:内半径(radius)字段是必需的。。如果未指定,则半径的单位将默认为米。

排序和检索索引的形状(Sorting and Retrieving index Shapes)

由于复杂的输入结构和形状的索引表示,目前不可能对形状进行分类或直接检索它们的字段。geo_shape值仅为检索通过_source field.

Previous3.2.1.2.复合数据类型Next3.2.1.4.特定数据类型

Last updated 5 years ago

Was this helpful?

All
Points