Skip to content

chapter43_part3: /404_Parent_Child/50_Has_child.asciidoc #276

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 5 commits into from
Oct 22, 2016

Conversation

weiqiangyuan
Copy link

No description provided.

The `has_child` query and filter can be used to find parent documents based on
the contents of their children.((("has_child query and filter")))((("parent-child relationship", "finding parents by their children"))) For instance, we could find all branches that
have employees born after 1980 with a query like this:
=== 根据子文档查询父文档

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.

ok,按照建议修改


`has_child` 的 query 和 filter 可以根据子文档的内容来查询父文档。((("has_child query and filter")))((("parent-child relationship", "finding parents by their children")))例如,我们根据如下查询,可查出所有出生在1980年之后的雇员所在的公司:
Copy link

@luotitan luotitan Sep 21, 2016

Choose a reason for hiding this comment

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

has_child 查询和过滤可以用来通过子文档的内容查询父文档。
出生在1980年之后的雇员 可以翻译成 80后员工
branches 还是翻译成“分支机构”吧。

Copy link
Author

Choose a reason for hiding this comment

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

ok,按照建议修改

depends on the `score_mode` parameter. The default setting is `none`, which
ignores the child scores and assigns a score of `1.0` to the parents, but it
also accepts `avg`, `min`, `max`, and `sum`.
`has_child` query 和 <<nested-query,`nested` query>> 类似,查询返回的结果都可以包括多个子文档((("has_child query and filter", "query"))),并且每一个子文档的评分值都不同。但是由于每一个子文档都带有评分,因此父文档的评分需要取决于 `score_mode` 这个参数。该参数有多种取值策略:默认为 `none` ,会忽略子文档的评分,并且会给父文档评分设置为 `1.0` ;

Choose a reason for hiding this comment

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

第一句 建议: 类似于 <<nested-query,nested query>> ,has_child 查询可以匹配多个子文档
评分值 -> 评分
后面这句不是非常准确:这些评分如何规约成父文档的总得分取决于 score_mode 这个参数。

Copy link
Author

Choose a reason for hiding this comment

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

ok,按照建议修改

ignores the child scores and assigns a score of `1.0` to the parents, but it
also accepts `avg`, `min`, `max`, and `sum`.
`has_child` query 和 <<nested-query,`nested` query>> 类似,查询返回的结果都可以包括多个子文档((("has_child query and filter", "query"))),并且每一个子文档的评分值都不同。但是由于每一个子文档都带有评分,因此父文档的评分需要取决于 `score_mode` 这个参数。该参数有多种取值策略:默认为 `none` ,会忽略子文档的评分,并且会给父文档评分设置为 `1.0` ;
还可以设置成 `avg` 、 `min` 、 `max` 和 `sum` 。

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.

ok,按照建议修改

The following query will return both `london` and `liverpool`, but `london`
will get a better score because `Alice Smith` is a better match than
`Barry Smith`:
下面的查询将会返回 `london` 和 `liverpool` 。由于 `Alice Smith` 要比 `Barry Smith` 更加匹配查询条件,因此 `london` 会得到一个更高的评分。

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.

ok,按照建议修改


This query will match only branches that have at least two employees:
如下查询只会返回至少有两个雇员的分公司:

Choose a reason for hiding this comment

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

和上面统一吧,要么分公司,要么分支机构,都OK

Copy link
Author

Choose a reason for hiding this comment

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

ok,按照建议修改

@@ -82,21 +68,14 @@ GET /company/branch/_search
}
}
-------------------------
<1> A branch must have at least two employees in order to match.
<1> 至少有两个雇员的分公司才会符合查询条件。

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.

都叫分公司了

The performance of a `has_child` query or filter with the `min_children` or
`max_children` parameters is much the same as a `has_child` query with scoring
enabled.
带有 `has_child` 、 `min_children` 和 `max_children` 参数的 query 或者 filter,在性能上都没有显著差异。
Copy link

@luotitan luotitan Sep 21, 2016

Choose a reason for hiding this comment

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

查询和过滤,同上
翻译的不够准确,min_childrenmax_children是修饰 has_child的,建议翻译成:
带有 min_childrenmax_children 参数的 has_child 查询或过滤,和 允许评分的 has_child 查询性能非常接近。

Copy link
Author

Choose a reason for hiding this comment

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

ok,按照建议修改


`has_child` filter 本身的结果不可被缓存,但是其内部 filter 的结果是可以被缓存的。

Choose a reason for hiding this comment

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

has_child 过滤的结果没有被缓存,但是 has_child 过滤 内部 的过滤方法适用于通过的缓存规则。

Copy link
Author

Choose a reason for hiding this comment

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

ok,按照建议修改


While the results of a `has_child` filter are not cached, the usual caching
rules apply to the filter _inside_ the `has_child` filter.
`has_child` filter 和 `has_child` query 在运行机制上类似,((("has_child query and filter", "filter")))区别是 `has_child` filter 不支持 `source_mode` 参数。`has_child` filter 只可以用在 filter 的上下文中(例如在 `filtered` query 中)并且和其他任何的 filter 一样:结果存在,或者不存在,并且没有评分机制。

Choose a reason for hiding this comment

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

查询 过滤 这两个还是要翻译的,请都检查下。
翻译有遗漏 : 它仅用于 筛选内容 — (这是一个符号,不要丢)如内部的一个 filtered 查询--和其他过滤行为类似:包含或者排除,但没有进行评分。

Copy link
Author

Choose a reason for hiding this comment

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

ok,按照建议修改

Copy link
Author

Choose a reason for hiding this comment

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

ok,按照建议修改

@luotitan
Copy link

LGTM

@medcl
Copy link
Member

medcl commented Oct 21, 2016

LGTM

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

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

* revise according comment

* revise according comment

* revise according comment

* revise according comment
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.

3 participants