Skip to content
This repository was archived by the owner on Sep 21, 2021. It is now read-only.

Chapter/chapter04 part20 #751

Open
wants to merge 131 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
131 commits
Select commit Hold shift + click to select a range
13fd1c2
chapter46_part4: /510_Deployment/40_config.asciidoc
pengqiuyuan Mar 4, 2016
3e8c673
Fixed typo
baakind Nov 25, 2015
79d3923
Add missing closing parenthesis
orangejulius Dec 11, 2015
e193083
typo
jpcarey Feb 2, 2016
7e728f4
510_Deployment_20_hardware的翻译
pengqiuyuan Mar 2, 2016
277cdda
chapter7_part2: /510_Deployment/20_hardware.asciidoc
pengqiuyuan Mar 2, 2016
61ecfa1
chapter46_part2: /510_Deployment/20_hardware.asciidoc
pengqiuyuan Mar 2, 2016
0ae9751
chapter46_part2: /510_Deployment/20_hardware.asciidoc
pengqiuyuan Mar 2, 2016
fcbf756
chapter46_part2: /510_Deployment/20_hardware.asciidoc
pengqiuyuan Mar 2, 2016
8690e60
510_Deployment/20_hardware.asciidoc
pengqiuyuan Mar 3, 2016
2c27bfb
chapter46_part2: /510_Deployment/20_hardware.asciidoc
pengqiuyuan Mar 3, 2016
e206962
chapter46_part2: /510_Deployment/20_hardware.asciidoc
pengqiuyuan Mar 3, 2016
d20ed67
chapter46_part2: /510_Deployment/20_hardware.asciidoc
pengqiuyuan Mar 3, 2016
ff6ba38
chapter46_part2: /510_Deployment/20_hardware.asciidoc
pengqiuyuan Mar 3, 2016
facb70f
chapter46_part2: /510_Deployment/20_hardware.asciidoc
pengqiuyuan Mar 3, 2016
bb8f539
chapter46_part2: /510_Deployment/20_hardware.asciidoc
pengqiuyuan Mar 3, 2016
bae79c3
chapter46_part2: /510_Deployment/20_hardware.asciidoc
pengqiuyuan Mar 4, 2016
c3bb310
chapter46_part2: /510_Deployment/20_hardware.asciidoc
pengqiuyuan Mar 4, 2016
b62ab4a
chapter44_part1: 410_Scaling/10_Intro.asciidoc
biyuhao Mar 5, 2016
3e31f3e
chapter5_part1: /50_Search/00_Intro.asciidoc
pengqiuyuan Mar 3, 2016
676b7af
Merge branch 'cn' of github.com:elasticsearch-cn/elasticsearch-defini…
medcl Mar 9, 2016
2f9ceee
chapter46_part4: /510_Deployment/40_config.asciidoc
pengqiuyuan Mar 10, 2016
cdefc20
Merge remote-tracking branch 'elasticsearch-cn/cn' into chapter/chapt…
pengqiuyuan Mar 11, 2016
bd75d0b
chapter46_part4: /510_Deployment/40_config.asciidoc
pengqiuyuan Mar 11, 2016
8c56850
chapter46_part4: /510_Deployment/40_config.asciidoc
pengqiuyuan Mar 11, 2016
27bc2c2
chapter12_part2: /080_Structured_Search/10_compoundfilters.asciidoc
richardwei2008 Mar 11, 2016
10cb12f
chapter12_part3: /080_Structured_Search/10_compoundfilters.asciidoc
richardwei2008 Mar 12, 2016
935de69
chapter46_part4: /510_Deployment/40_config.asciidoc
pengqiuyuan Mar 14, 2016
ca9acfd
chapter13_part1: /100_Full_Text_Search/10_Multi_word_queries.asciidoc
richardwei2008 Mar 14, 2016
26de281
chapter46_part2: /510_Deployment/45_dont_touch.asciidoc
pengqiuyuan Mar 14, 2016
c40a6be
chapter13_part4: /100_Full_Text_Search/chapter13_part1: /100_Full_Tex…
richardwei2008 Mar 14, 2016
db0895b
chapter45_part1:/500_Cluster_Admin/10_intro.asciidoc
chenryn Mar 15, 2016
dae095b
chapter46_part2: /510_Deployment/45_dont_touch.asciidoc
pengqiuyuan Mar 30, 2016
46a366b
chapter46_part6: /510_Deployment/50_heap.asciidoc
pengqiuyuan Mar 31, 2016
d9a2851
Merge pull request #68 from pengqiuyuan/chapter/chapter46_part6_1
medcl Mar 31, 2016
cbba8f8
Merge pull request #29 from richardwei2008/p2_chapter12/10_compoundfi…
medcl Mar 31, 2016
7aa98a4
Merge pull request #40 from pengqiuyuan/chapter/chapter46_part5
medcl Mar 31, 2016
89f8e5b
Merge pull request #45 from richardwei2008/p2_chapter13/15_Combining_…
medcl Mar 31, 2016
6dd6fc5
Merge pull request #44 from richardwei2008/p2_chapter13/10_Multi_word…
medcl Mar 31, 2016
3764c8d
Merge branch 'cn' of github.com:elasticsearch-cn/elasticsearch-defini…
medcl Mar 31, 2016
c3811bb
Merge branch 'master' into cn
medcl Mar 31, 2016
6fd9005
020_Distributed_Cluster/00_Intro.asciidoc 翻译
michealzh Apr 4, 2016
7680b32
Merge pull request #51 from chenryn/chapter45_part1
medcl Apr 5, 2016
e4e86b9
chapter46_part4: /510_Deployment/40_config.asciidoc
pengqiuyuan Apr 12, 2016
c9eed37
chapter14_part1: /110_Multi_Field_Search/00_Intro.asciidoc
richardwei2008 Apr 13, 2016
bf6351f
fix English quota
richardwei2008 Apr 14, 2016
fab2c22
chapter17_part1: /130_Partial_Matching/05_Intro.asciidoc
richardwei2008 Apr 18, 2016
45dcc5d
chapter17_part13: /170_Relevance/65_Script_score.asciidoc
richardwei2008 Apr 22, 2016
8888721
Merge pull request #86 from richardwei2008/p2_chapter14/00_Intro
medcl May 1, 2016
c5c1f89
Merge pull request #26 from pengqiuyuan/chapter/chapter46_part4
medcl May 1, 2016
b51b446
chapter4_part1
dajyaretakuya May 17, 2016
07db8c8
chapter4_part1
dajyaretakuya May 17, 2016
3146123
修改
richardwei2008 May 20, 2016
852a1ea
Merge pull request #72 from michealzh/chapter/chapter010_part10
michealzh May 31, 2016
d08e689
Revert "020_Distributed_Cluster/00_Intro.asciidoc 翻译"
medcl May 31, 2016
41d7ad6
Merge pull request #138 from elasticsearch-cn/revert-72-chapter/chapt…
medcl May 31, 2016
7431804
Merge pull request #124 from richardwei2008/p2_chapter17/65_Script_score
medcl May 31, 2016
dbc8eaa
Merge pull request #112 from richardwei2008/p2_chapter17/05_Intro
medcl May 31, 2016
89e02f9
Update 85_Sorting.asciidoc
fanyer Jul 20, 2016
dfe7b91
Update 85_Sorting.asciidoc
fanyer Jul 20, 2016
3751505
Update 85_Sorting.asciidoc
fanyer Jul 20, 2016
1dd977a
Update 85_Sorting.asciidoc
fanyer Jul 20, 2016
819cf23
Update 85_Sorting.asciidoc
fanyer Jul 20, 2016
46ff94f
Update 85_Sorting.asciidoc
fanyer Jul 20, 2016
c57793c
Update 88_String_sorting.asciidoc
fanyer Jul 20, 2016
b811bc1
daily update
fanyer Jul 20, 2016
51049d4
daily refresh
fanyer Jul 20, 2016
75aff0a
fixed unfit edition
fanyer Jul 20, 2016
61b24a0
no message
fanyer Jul 20, 2016
1e50bd0
chapter8_part2
fanyer Jul 20, 2016
138a24e
/ 056_Sorting/ 88_String_sorting.asciidoc
fanyer Jul 20, 2016
1b179c5
refresh 字段数据
fanyer Jul 21, 2016
d553082
error fixed
fanyer Jul 21, 2016
e29b6cb
相关性
fanyer Jul 22, 2016
424f2fd
第一次提交
luotitan Jul 23, 2016
eb46ca8
第一次提交
luotitan Jul 24, 2016
0379912
Merge pull request #144 from luotitan/chapter/chapter24_part6
looly Jul 26, 2016
50173e8
Merge pull request #143 from luotitan/chapter/chapter24_part5
looly Jul 26, 2016
f8e3094
Merge pull request #142 from fanyer/chapter/chapter8_part3
looly Jul 26, 2016
64edbb9
Merge pull request #141 from fanyer/chapter/chapter8_part4
looly Jul 26, 2016
5ddf939
Merge pull request #140 from fanyer/chapter/chapter8_part2
looly Jul 26, 2016
d818ea4
Revert "chapter8_part4: /056_Sorting/95_Fielddata.asciidoc"
looly Jul 26, 2016
8a7efca
Revert "chapter24_part6: /270_Fuzzy_matching/60_Phonetic_matching.asc…
looly Jul 26, 2016
87d08dc
Revert "chapter24_part5: /270_Fuzzy_matching/50_Scoring_fuzziness.asc…
looly Jul 26, 2016
ef1fc4c
Merge pull request #147 from elasticsearch-cn/revert-143-chapter/chap…
medcl Jul 29, 2016
5c7e9a9
Merge pull request #146 from elasticsearch-cn/revert-144-chapter/chap…
medcl Jul 29, 2016
757a196
Merge pull request #145 from elasticsearch-cn/revert-141-chapter/chap…
medcl Jul 29, 2016
83e147b
merge upstream, fix build error
medcl Jul 29, 2016
df1c138
Revert "chapter8_part3: /056_Sorting/90_What_is_relevance.asciidoc"
medcl Jul 29, 2016
51505d1
Merge pull request #150 from elasticsearch-cn/revert-142-chapter/chap…
medcl Jul 29, 2016
bbf4550
Revert "chapter8_part2: /056_Sorting/88_String_sorting.asciidoc"
medcl Jul 29, 2016
35500ef
Merge pull request #151 from elasticsearch-cn/revert-140-chapter/chap…
medcl Jul 29, 2016
8eb7582
fix sorting use old fielddata tag
medcl Jul 29, 2016
a1fbbfd
Merge pull request #152 from medcl/cn
medcl Jul 29, 2016
3a1d87c
00_Intro is finished
Aug 1, 2016
b390183
chapter24_part4: /270_Fuzzy_matching/40_Fuzzy_match_query.asciidoc (#…
luotitan Aug 8, 2016
d867e48
chapter41_part3: /400_Relationships/20_Denormalization.asciidoc (#67)
luotitan Aug 8, 2016
c283d67
chapter16_part2: /130_Partial_Matching/05_Postcodes.asciidoc (#102)
richardwei2008 Aug 8, 2016
91aa123
translate chapter/chapter05_part1
calm4wei Sep 1, 2016
9cd3ac1
modify
calm4wei Sep 1, 2016
925873f
060_Distributed_Search
Sep 8, 2016
9a773f1
Merge pull request #253 from JessicaWon/060_Distributed_Search/chapte…
Sep 8, 2016
d17be7c
Revert "060 distributed search/00_Intro.asciidoc and 05_Query_phase.a…
Sep 8, 2016
b1366a0
chapter9_part1: /060_Distributed_Search/00_Intro.asciidoc
Sep 8, 2016
2fa8945
Merge pull request #271 from elasticsearch-cn/revert-253-060_Distribu…
luotitan Sep 10, 2016
76eee1a
Update 00_Intro.asciidoc
Sep 12, 2016
7d1860c
commit 050_search part2
calm4wei Sep 12, 2016
430d826
modified: 00_Intro.asciidoc
Oct 17, 2016
e603218
Merge pull request #255 from JessicaWon/chapter/chapter9_part1
Oct 17, 2016
d688a06
Revert "chapter9_part1: /060_Distributed_Search/00_Intro.asciidoc"
luotitan Oct 17, 2016
73e3f55
Merge pull request #320 from elasticsearch-cn/revert-255-chapter/chap…
luotitan Oct 17, 2016
dab560f
chapter10_part2:/070_Index_Mgmt/10_Settings.asciidoc (#297)
yichao2015 Oct 17, 2016
a68b540
chapter10_part8:/070_Index_Mgmt/32_Metadata_all.asciidoc (#300)
yichao2015 Oct 17, 2016
0b46e8a
chapter10_part13:070_Index_Mgmt/50_Reindexing.asciidoc (#309)
cdma Oct 21, 2016
5aa3bbe
chapter10_part12:/070_Index_Mgmt/45_Default_Mapping.asciidoc (#299)
yichao2015 Oct 21, 2016
1f8d21b
chapter10_part9: /070_Index_Mgmt/33_Metadata_ID.asciidoc (#196)
luotitan Oct 21, 2016
5a6c9f5
resolve conflicts
medcl Oct 21, 2016
f4f58c9
Merge branch 'dajyaretakuya-chapter/chapter4_part1' into cn
medcl Oct 21, 2016
d3b7f34
Merge branch 'cn' of github.com:elasticsearch-cn/elasticsearch-defini…
medcl Oct 21, 2016
a6dc877
chapter9_part1: /060_Distributed_Search/00_Intro.asciidoc (#321)
luotitan Oct 21, 2016
c654149
chapter43_part2: /404_Parent_Child/45_Indexing_parent_child.asciidoc …
weiqiangyuan Oct 22, 2016
5f8c44f
chapter47_part3:/520_Post_Deployment/30_indexing_perf.asciidoc (#56)
chenryn Oct 22, 2016
1a1c25a
chapter38_part1:/320_Geohashes/40_Geohashes.asciidoc (#305)
Oct 22, 2016
175866d
chapter43_part4: /404_Parent_Child/55_Has_parent.asciidoc (#277)
weiqiangyuan Oct 22, 2016
e42e492
chapter43_part1: /404_Parent_Child/40_Parent_child.asciidoc (#275)
weiqiangyuan Oct 22, 2016
6e64048
chapter43_part3: /404_Parent_Child/50_Has_child.asciidoc (#276)
weiqiangyuan Oct 22, 2016
712085a
chapter43_part5: /404_Parent_Child/60_Children_agg.asciidoc (#278)
weiqiangyuan Oct 22, 2016
95ad256
fix filename (#325)
medcl Oct 22, 2016
774df15
10_Multi
calm4wei Oct 22, 2016
1521c5c
Merge pull request #284 from calm4wei/chapter05_part2/050_Search/10_M…
calm4wei Oct 22, 2016
6acb4e4
Revert "chapter05_part2:/050_Search/10_Multi_index_multi_type.asciido…
medcl Oct 22, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chapter43_part1: /404_Parent_Child/40_Parent_child.asciidoc (#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 一
weiqiangyuan authored and medcl committed Oct 22, 2016
commit e42e492e9c1d1611975d7ddb14bfd1b7d77b7c26
54 changes: 13 additions & 41 deletions 404_Parent_Child/40_Parent_child.asciidoc
Original file line number Diff line number Diff line change
@@ -1,54 +1,26 @@
[[parent-child]]
== Parent-Child Relationship
== 父-子关系文档

The _parent-child_ relationship is ((("relationships", "parent-child")))((("parent-child relationship")))similar in nature to the
<<nested-objects,nested model>>: both allow you to associate one entity
with another. ((("nested objects", "parent-child relationships versus")))The difference is that, with nested objects, all entities live
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>> 文档中,所有对象都是在同一个文档中,而在父-子关系文档中,父对象和子对象都是完全独立的文档。

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 的文档关联起来,构成一对多的关系:一个父文档可以对应多个子文档 ((("one-to-many relationships"))) 。与 <<nested-objects,`nested` objects>> 相比,父-子关系的主要优势有:

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

* 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.

* Child documents can be returned as the results of a search request.

Elasticsearch maintains a map of which parents are associated with
which children. It is thanks to this map that query-time joins are fast, but
it does place a limitation on the parent-child relationship: _the parent
document and all of its children must live on the same shard_.

The parent-child ID maps are stored in <<docvalues>>, which allows them to execute
quickly when fully hot in memory, but scalable enough to spill to disk when
the map is very large.
Elasticsearch 维护了一个父文档和子文档的映射关系,得益于这个映射,父-子文档关联查询操作非常快。但是这个映射也对父-子文档关系有个限制条件:父文档和其所有子文档,都必须要存储在同一个分片中。

父-子文档ID映射存储在 <<docvalues>> 中。当映射完全在内存中时, <<docvalues>> 提供对映射的快速处理能力,另一方面当映射非常大时,可以通过溢出到磁盘提供足够的扩展能力

[[parent-child-mapping]]
=== Parent-Child Mapping
=== 父-子关系文档映射

All that is needed in order to establish the parent-child relationship is to
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。

As an example, let's say that we have a company that has branches in many
cities. We would like to associate employees with the branch where they work.
We need to be able to search for branches, individual employees, and employees
who work for particular branches, so the nested model will not help. We
could, of course,
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>> 也是可以实现的,但是为了演示的目的,在这里我们使用父-子文档。

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:
我们需要告诉Elasticsearch,在创建员工 `employee` 文档 type 时,指定分公司 `branch` 的文档 type 为其父亲。

[source,json]
-------------------------
@@ -64,4 +36,4 @@ PUT /company
}
}
-------------------------
<1> Documents of type `employee` are children of type `branch`.
<1> `employee` 文档 是 `branch` 文档的子文档。