Skip to content

Commit

Permalink
chapter40_part5:/340_Geoshapes/78_Indexed_geo_shapes.asciidoc (elasti…
Browse files Browse the repository at this point in the history
  • Loading branch information
Rex authored and medcl committed Nov 21, 2016
1 parent abb174c commit 9723f77
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions 340_Geoshapes/78_Indexed_geo_shapes.asciidoc
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
[[indexed-geo-shapes]]
=== Querying with Indexed Shapes
=== 在查询中使用已索引的形状

With shapes that are often used in queries, it can be more convenient to store
them in the index and to refer to them by name in the query.((("indexed shapes, querying with")))((("geo-shapes", "querying with indexed shapes"))) Take our example
of central Amsterdam in the previous example. We could store it as a document
of type `neighborhood`.
对于那些经常会在查询中使用的形状,可以把它们索引起来以便在查询中可以方便地直接引用名字。((("indexed shapes, querying with")))((("geo-shapes", "querying with indexed shapes")))以之前的阿姆斯特丹中部为例,我们可以把它存储成一个类型为 `neighborhood` 的文档。

First, we set up the mapping in the same way as we did for `landmark`:
首先,我们仿照之前设置 `landmark` 时的方式建立映射:

[source,json]
-----------------------
Expand All @@ -23,7 +20,7 @@ PUT /attractions/_mapping/neighborhood
}
-----------------------

Then we can index a shape for central Amsterdam:
然后我们索引阿姆斯特丹中部对应的形状:

[source,json]
-----------------------
Expand All @@ -49,8 +46,7 @@ PUT /attractions/neighborhood/central_amsterdam
}
-----------------------

After the shape is indexed, we can refer to it by `index`, `type`, and `id` in the
query itself:
形状索引好之后,我们就可以在查询中通过 `index` , `type` 和 `id` 来引用它了:

[source,json]
-----------------------
Expand All @@ -71,13 +67,9 @@ GET /attractions/landmark/_search
}
}
-----------------------
<1> By specifying `indexed_shape` instead of `shape`, Elasticsearch knows that
it needs to retrieve the query shape from the specified document and
`path`.
<1> 指定 `indexed_shape` 而不是 `shape` ,Elasticesearch 就知道需要从指定的文档和 `path` 检索出对应的形状了。

There is nothing special about the shape for central Amsterdam. We could
equally use our existing shape for Dam Square in queries. This query finds
neighborhoods that intersect with Dam Square:
阿姆斯特丹中部这个形状没有什么特别的。同样地,我们也可以在查询中使用已经索引好的达姆广场。这个查询可以找出与达姆广场有交集的临近点:

[source,json]
-----------------------
Expand Down

0 comments on commit 9723f77

Please sign in to comment.