当前位置: 首页 > elasticsearch, 搜索 > 正文

翻译 elasticsearch _routing

关键字:
1 星2 星3 星4 星5 星 (1 次投票, 评分: 5.00, 总分: 5)
Loading ... Loading ...
baidu_share

原文地址:http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-routing-field.html

The routing field allows to control the _routing aspect when indexing data and explicit routing control is required.
当索引数据和明确路由控制是需要的,路由字段允许控制_routing方向。也就是_routing可以控制索引数据去哪里。

store / index(索引/存储)

The first thing the _routing mapping does is to store the routing value provided (store set to yes) and index it (index set to not_analyzed). The reason why the routing is stored by default is so reindexing data will be possible if the routing value is completely external and not part of the docs.

第一件事情就是路由映射去存储路由提供的值(存储设置为yes)和索引它(索引设置为not_analyzed)。如果完全是外部路由值而不是文档的一部分,在默认情况下,路由被存储是为了使重新索引数据成为可能。

required(需要)

Another aspect of the _routing mapping is the ability to define it as required by setting required to true. This is very important to set when using routing features, as it allows different APIs to make use of it. For example, an index operation will be rejected if no routing value has been provided (or derived from the doc). A delete operation will be broadcasted to all shards if no routing value is provided and _routing is required.

另一个方面的_routing映射是将它定义为通过设置需要required为true。使用时要设置路由功能,这是非常重要的,因为它允许不同的API来利用它。例如,如果没有路由值提供(或来自文档的路由值),索引操作将被拒绝。如果没有路由值被提供和_routing被需要的,A删除操作将被广播到所有分片。

path(路径)

The routing value can be provided as an external value when indexing (and still stored as part of the document, in much the same way _source is stored). But, it can also be automatically extracted from the index doc based on a path. For example, having the following mapping:

路由值作为外部值时,可以提供索引(存储文档一部分,存储方式大致和_source相同)。但是,它也可以被自动提取到索引doc根据路径上。例如,有下面的映射:

{
    "comment" : {
        "_routing" : {
            "required" : true,
            "path" : "blog.post_id"
        }
    }
}

Will cause the following doc to be routed based on the 111222 value:
将导致下面文档被路由的值为11222:

{
    "comment" : {
        "_routing" : {
            "required" : true,
            "path" : "blog.post_id"
        }
    }
}

Note, using path without explicit routing value provided required an additional (though quite fast) parsing phase.

注意,使用没有明确的路由路径值,需要额外的解析(虽然相当快)。

id uniqueness(id惟一)

When indexing documents specifying a custom _routing, the uniqueness of the _id is not guaranteed throughout all the shards that the index is composed of. In fact, documents with the same _id might end up in different shards if indexed with different _routing values.

当索引文档确定一个custom _routing,_id唯一性不能担保所有各个分片是由索引组成的。事实上,如果索引使用不同_routing值,文档将用同一个_id结束在不同的分片。即文档路由分片通过_id来完成

本文固定链接: http://www.chepoo.com/translate-elasticsearch-_routing.html | IT技术精华网

翻译 elasticsearch _routing:等您坐沙发呢!

发表评论