-
Notifications
You must be signed in to change notification settings - Fork 1.5k
chapter43_part4: /404_Parent_Child/55_Has_parent.asciidoc #277
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,9 @@ | ||
[[has-parent]] | ||
=== Finding Children by Their Parents | ||
=== 根据父文档查询子文档 | ||
|
||
While a `nested` query can always ((("parent-child relationship", "finding children by their parents")))return only the root document as a result, | ||
parent and child documents are independent and each can be queried | ||
independently. The `has_child` query allows us to return parents based on | ||
data in their children, and the `has_parent` query returns children based on | ||
data in their parents.((("has_parent query and filter", "query"))) | ||
`nested` query 只能返回最顶层的文档 ((("parent-child relationship", "finding children by their parents"))),而在父-子文档中,父文档和子文档都是独立的,并且可以被单独地查询出来。`has_child` 实现了根据子文档的数据内容来查询父文档,类似我们也有 `has_parent` ,实现了根据父文档的数据内容来查询子文档((("has_parent query and filter", "query")))。 | ||
|
||
It looks very similar to the `has_child` query. This example returns | ||
employees who work in the UK: | ||
`has_parent` 和 `has_child` 非常相似,下面的查询将会返回所有在 UK 工作的雇员: | ||
|
||
[source,json] | ||
------------------------- | ||
|
@@ -26,19 +21,13 @@ GET /company/employee/_search | |
} | ||
} | ||
------------------------- | ||
<1> Returns children who have parents of type `branch` | ||
<1> 指定子文档对应的父文档 type 是 `branch` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 按照原意 翻译会更好一些吧 返回父文档 type 是 😄 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok,按照要求修改 |
||
|
||
The `has_parent` query also supports the `score_mode`,((("score_mode parameter"))) but it accepts only two | ||
settings: `none` (the default) and `score`. Each child can have only one | ||
parent, so there is no need to reduce multiple scores into a single score for | ||
the child. The choice is simply between using the score (`score`) or not | ||
(`none`). | ||
`has_parent` query 也支持 `score_mode` 这个参数,((("score_mode parameter")))但是该参数只支持两种值: `none` (默认)和 `score` 。因为每一个子文档都只有一个父文档,对子文档而言并不需要在多个评分中进行筛选,因此 `score_mode` 就很简单,取值仅为 `score` 和 `none` 。 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个query 是否应该翻译为中文? 下面这个改成如下是否更通顺? 每个子文档都只有一个父文档,因此这里不存在将多个评分规约为一个的情况,取值仅为 使用分数 ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok,按照要求修改 |
||
|
||
.Non-scoring has_parent Query | ||
.不带评分的 has_parent 查询 | ||
************************** | ||
|
||
When used in non-scoring mode (e.g. inside a `filter` clause), the `has_parent` | ||
query no longer supports the `score_mode` parameter. Because it is merely | ||
including/excluding documents and not scoring, the `score_mode` parameter | ||
no longer applies. | ||
当不需要评分时(例如:在一个 `filter` 查询语句中),`has_parent` 不支持 `source_mode` 参数。因为 filter 查询的结果仅是存在或者不存在并且不需要评分,因此 `source_mode` 这个参数也就不需要了。 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 当 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok,按照要求修改 |
||
|
||
************************** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
改为
虽然
nested
query 只能返回父级文档,但是父子文档本身是彼此独立并且可被单独查询的。是否更通顺一些?
我们使用
has_child
语句可以基于子文档来查询父文档,使用has_parent
语句可以基于子文档来查询父文档。There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok,按照要求修改