Skip to content

chapter43_part1: /404_Parent_Child/40_Parent_child.asciidoc #275

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 22, 2016

Conversation

weiqiangyuan
Copy link

No description provided.

within the same document while, with parent-child, the parent and children
are completely separate documents.
父-子关系文档((("relationships", "parent-child")))((("parent-child relationship")))和
<<nested-objects,nested model>> 有一个相似点:允许将一个对象实体和另外一个对象实体关联起来。((("nested objects", "parent-child relationships versus")))而这两种类型的主要区别是:在 在 <<nested-objects,`nested` objects>> 文档中,所有对象都是在同一个文档中,而在父-子关系文档中,父对象和子对象都是完全独立的文档。
Copy link

@cdma cdma Sep 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议:1. 改成在实质上类似于xxx
2. (((这种符号好像都要留空格

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, 按照给出的建议修改

The parent-child functionality allows you to associate one document type with
another, in a _one-to-many_ relationship--one parent to many children.((("one-to-many relationships"))) The
advantages that parent-child has over <<nested-objects,`nested` objects>> are as follows:
父-子关系的主要作用是允许把一个 type 的文档和另外一个 type 的文档关联起来,构成1对n的关系:一个父文档可以对应多个子文档((("one-to-many relationships")))。与 <<nested-objects,`nested` objects>> 相比,父-子关系的主要优势有:
Copy link

@cdma cdma Sep 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议:1. 这里document就是指type,翻译中去掉type的
2. 一对多的关系
3. 格式符号都要留空格

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

关于第一条,我觉得type保留下来,能够更加清楚地说明P-C是关联不同type类型的文档(而不是用来关联同一个type下的不同文档)。
第2、3条按照建议修改。

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可能一对多更好,当然1对多也看得懂

* The parent document can be updated without reindexing the children.
* 更新父文档时,不会重新索引子文档。
* 创建,修改或删除子文档时,不会影响父文档和其他子文档。这一点在这种场景下尤其有用:子文档数量较多,并且子文档创建和修改的频率高时。
* 子文档可以作为搜索结果,独立返回。
Copy link

@cdma cdma Sep 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

父文档其他子文档
子文档可以作为搜索结果独立返回(不要逗号)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

按照给出的建议修改

* Child documents can be added, changed, or deleted without affecting either
the parent or other children. This is especially useful when child documents
are large in number and need to be added or changed frequently.
Elasticsearch 维护了一个父文档和子文档的映射关系——ID maps,实现了快速的父-子文档查询操作。但是,有一点需要指出:父文档和其所有子文档,都必须要存储在同一个分片中。
Copy link

@cdma cdma Sep 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议:1. 去掉——ID maps
2. 得益于这个映射,父-子文档关联查询操作非常快
3. 但是这个映射也对父-子文档关系有个限制条件

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

按照给出的建议修改


* Child documents can be returned as the results of a search request.
ID maps 维护在 <<docvalues>> 中。通过 <<docvalues>>,可以将热点查询的 ID maps 维护在内存中;当 ID maps 变得非常大时,还可以将其扩展加载到硬盘中。
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议:

  1. 父-子文档ID映射存储在
  2. which allows them to execute quickly when fully hot in memory这句我也没有好的翻译方法,建议请教下其他人

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

第1个建议按照要求修改。第2个在请教中



[[parent-child-mapping]]
=== Parent-Child Mapping
=== 父-子映射
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

父-子文档映射

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

按照给出的建议修改

specify which document type should be the parent of a child type.((("mapping (types)", "parent-child")))((("parent-child relationship", "parent-child mapping"))) This must
be done at index creation time, or with the `update-mapping` API before the
child type has been created.
建立父-子映射关系时需要指定某一个文档 type 是另一个文档 type 的父亲。((("mapping (types)", "parent-child")))((("parent-child relationship", "parent-child mapping")))该关系可以在如下两个时间点设置:1)创建索引时;2)在子文档的 type 创建之前,通过更新父文档的 mapping。
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.只需要
2. update-mapping API不要翻译

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

按照给出的建议修改

use <<application-joins,application-side-joins>> or
<<denormalization,data denormalization>> here instead, but for demonstration
purposes we will use parent-child.
举例说明,有一个公司在多个城市有分公司,并且每一个分公司下面都有很多员工。有这样的需求:按照分公司、员工的维度去搜索,并且搜索某些特定分公司下的员工。针对该需求,用嵌套模型是无法实现的。当然,如果使用 <<application-joins,application-side-joins>> 或者 <<denormalization,data denormalization>> 也是可以实现的。
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 我们想把员工和他们工作的分公司联系起来

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

All that we have to do is to tell Elasticsearch that the `employee` type has
the `branch` document type as its `_parent`, which we can do when we create
the index:
在这里我们使用父-子文档,首先需要父子文档的映射关系,我们在创建员工 `employee` 文档 type 时,指定分公司 `branch` 的文档 type 为其父亲。
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 但是为了演示的目的
  2. 我们需要告诉Elasticsearch

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

@cdma
Copy link

cdma commented Sep 26, 2016

LGTM

@medcl
Copy link
Member

medcl commented Oct 21, 2016

LGTM

@medcl medcl merged commit e42e492 into elasticsearch-cn:cn Oct 22, 2016
tangmisi pushed a commit to tangmisi/elasticsearch-definitive-guide that referenced this pull request Oct 31, 2016
…earch-cn#275)

* 完成Parent-Child第1部分的翻译

* revise nested model name

* reisve pull request according to first inner team review

* reisve pull request according to first inner team review

* revise docvalue and maps

* revise 1 to 一
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants