From c34fe5b6ec3ddb467586956a77ba4c1fb5bbbc98 Mon Sep 17 00:00:00 2001 From: "hua.chen" Date: Tue, 23 Aug 2016 00:02:33 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E7=AC=AC=E5=9B=9B=E7=AB=A0=E7=9A=84?= =?UTF-8?q?=E5=88=9D=E7=89=88=E7=BF=BB=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 240_Stopwords/40_Divide_and_conquer.asciidoc | 89 ++++++-------------- 1 file changed, 28 insertions(+), 61 deletions(-) diff --git a/240_Stopwords/40_Divide_and_conquer.asciidoc b/240_Stopwords/40_Divide_and_conquer.asciidoc index e7a3c524b..031f19d6d 100644 --- a/240_Stopwords/40_Divide_and_conquer.asciidoc +++ b/240_Stopwords/40_Divide_and_conquer.asciidoc @@ -1,31 +1,21 @@ [[common-terms]] -=== Divide and Conquer +=== 词条区分管理 -The terms in a query string can be divided into more-important (low-frequency) -and less-important (high-frequency) terms.((("stopwords", "low and high frequency terms"))) Documents that match only the less -important terms are probably of very little interest. Really, we want -documents that match as many of the more important terms as possible. +在查询字符串时,词条可以分为十分重要 (低频词) 和不太重要 (高频词) 。((("stopwords", "low and high frequency terms"))) 只匹配不太重要词条的文档,很可能是没有多少关联的文档. 然而,我们想 +尽可能多的比较重要的术语的匹配文档。 -The `match` query accepts ((("cutoff_frequency parameter")))((("match query", "cutoff_frequency parameter")))a `cutoff_frequency` parameter, which allows it to -divide the terms in the query string into a low-frequency and high-frequency -group.((("term frequency", "cutoff_frequency parameter in match query"))) The low-frequency group (more-important terms) form the bulk of the -query, while the high-frequency group (less-important terms) is used only for -scoring, not for matching. By treating these two groups differently, we can -gain a real boost of speed on previously slow queries. -.Domain-Specific Stopwords +此`match`查询接受一个((("cutoff_frequency parameter")))((("match query", "cutoff_frequency parameter")))`cutoff_frequency`参数,它允许在查询字符串的词条划分成低频和高频组。((("term frequency", "cutoff_frequency parameter in match query")))低频组(十分重要的术语)形成了大量的查询,而高频率组(不太重要的术语)只为用于评分计算,不匹配。通过区别对待这两组词条,我们可以 +对以前的慢查询获得速度上的提高作用。 + +.特定领域停用词 ********************************************* -One of the benefits of `cutoff_frequency` is that you get _domain-specific_ -stopwords for free.((("domain specific stopwords")))((("stopwords", "domain specific"))) For instance, a website about movies may use the words -_movie_, _color_, _black_, and _white_ so often that they could be -considered almost meaningless. With the `stop` token filter, these domain-specific terms would have to be added to the stopwords list manually. However, -because the `cutoff_frequency` looks at the actual frequency of terms in the -index, these words would be classified as _high frequency_ automatically. + `cutoff_frequency` 配置的好处是,你在 _特定领域_ 使用停用词不受约束。((("domain specific stopwords")))((("stopwords", "domain specific")))例如,关于电影网站使用的词 _movie_,_color_,_black_和_white_ ,这些词往往可能认为几乎没有任何意义。使用 `stop` 词汇单元过滤器,这些特定领域的词条必须手动添加到停用词列表中。然而, `cutoff_frequency` 着眼于这些词条的实际频率指数,这些词条会被自动归类为 _高频词汇_。 ********************************************* -Take this query as an example: +使用以下查询作为示例: [source,json] --------------------------------- @@ -37,13 +27,10 @@ Take this query as an example: } } --------------------------------- -<1> Any term that occurs in more than 1% of documents is considered to be high - frequency. The `cutoff_frequency` can be specified as a fraction (`0.01`) - or as an absolute number (`5`). +<1> 任何词条出现在文档中超过1%,被认为是高频率。`cutoff_frequency` 配置可以指定为一个分数(`0.01`)或者一个正整数(`5`)。 -This query uses the `cutoff_frequency` to first divide the query terms into a -low-frequency group (`quick`, `dead`) and a high-frequency group (`and`, -`the`). Then, the query is rewritten to produce the following `bool` query: +此查询通过`cutoff_frequency` 配置,将查询条件划分为低频率组 (`quick`, `dead`)和高频率组 (`and`, +`the`)。然后,此查询会被重写为以下的`bool` 查询: [source,json] --------------------------------- @@ -68,32 +55,22 @@ low-frequency group (`quick`, `dead`) and a high-frequency group (`and`, } } --------------------------------- -<1> At least one low-frequency/high-importance term _must_ match. -<2> High-frequency/low-importance terms are entirely optional. +<1> 必须匹配有一个低频且高重要性词条。 +<2> 高频/低重要性词条是完全可有可无。 -The `must` clause means that at least one of the low-frequency terms—`quick` or `dead`—_must_ be present for a document to be considered a -match. All other documents are excluded. The `should` clause then looks for -the high-frequency terms `and` and `the`, but only in the documents collected -by the `must` clause. The sole job of the `should` clause is to score a -document like ``Quick _and the_ dead'' higher than ``_The_ quick but -dead''. This approach greatly reduces the number of documents that need to be -examined and scored. +此处`must` 意味着低频率词汇—`quick` 或者 `dead`— 至少有一个匹配;必须存在一个词,此文档被认为是匹配的。所有其他的文档被排除在外。然后`should`子句查找高频词条 `and` 和 `the`,只是在`must` 子句查询的结果集文档中查询。 +`should`子句的唯一的工作就是文档中包含``Quick _and the_ dead''高于包含``_The_ quick but dead''的得分。这种做法大大减少需要进行检查的文档数目。  [TIP] ================================================== -Setting the operator parameter to `and` would make _all_ low-frequency terms -required, and score documents that contain _all_ high-frequency terms higher. -However, matching documents would not be required to contain all high-frequency terms. If you would prefer all low- and high-frequency terms to be -required, you should use a `bool` query instead. As we saw in -<>, this is already an efficient query. +设置操作参数为`and`,将使用所有低频词条都必须,得分较高是含有较多高频词条的文档。然而,匹配的文档中并不需要包含所有的高频词条。如果你希望所有的低频和高频词条都被指定为必须的。那么你应该使用`bool` 查询方式代替`match`查询。现在正如我们看到的<>,这个已经是一个很高效的查询。 ================================================== -==== Controlling Precision +==== 控制精度 -The `minimum_should_match` parameter can be combined with `cutoff_frequency` -but it applies to only the low-frequency terms.((("stopwords", "low and high frequency terms", "controlling precision")))((("minimum_should_match parameter", "controlling precision"))) This query: +`minimum_should_match`参数可用 `cutoff_frequency`组合使用,但是此参数仅适用与低频词条。((("stopwords", "low and high frequency terms", "controlling precision")))((("minimum_should_match parameter", "controlling precision")))如以下查询: [source,json] --------------------------------- @@ -107,7 +84,7 @@ but it applies to only the low-frequency terms.((("stopwords", "low and high fre } --------------------------------- -would be rewritten as follows: +将被重写为如下所示: [source,json] --------------------------------- @@ -133,18 +110,12 @@ would be rewritten as follows: } } --------------------------------- -<1> Because there are only two terms, the original 75% is rounded down - to `1`, that is: _one out of two low-terms must match_. -<2> The high-frequency terms are still optional and used only for scoring. +<1> 因为只有两个词,原来的75%向下取整为`1`,意思是:二分之一的低频词条必须匹配。 +<2> 高频词条仍可选的,并且仅用于评分使用。 -==== Only High-Frequency Terms +==== 高频词条 -An `or` query for high-frequency((("stopwords", "low and high frequency terms", "only high frequency terms"))) terms only—``To be, or not to be''—is -the worst case for performance. It is pointless to score _all_ the -documents that contain only one of these terms in order to return just the top -10 matches. We are really interested only in documents in which the terms all occur -together, so in the case where there are no low-frequency terms, the query is -rewritten to make all high-frequency terms required: +仅查询 `or` 高频((("stopwords", "low and high frequency terms", "only high frequency terms")))词条,对—``To be, or not to be''— 词条来说性能太糟糕啦。查询所有文档返回评分最高的前10个。我们真正的意图是查询整个—``To be, or not to be''—词条出现的文档,所以在这种情况下,不存低频所言,这个查询需要重写为所有高频词条都必须: [source,json] --------------------------------- @@ -162,15 +133,11 @@ rewritten to make all high-frequency terms required: } --------------------------------- -==== More Control with Common Terms +==== 对普通词条更多的控制 -While the high/low frequency functionality in the `match` query is useful, -sometimes you want more control((("stopwords", "low and high frequency terms", "more control over common terms"))) over how the high- and low-frequency groups -should be handled. The `match` query exposes a subset of the -functionality available in the `common` terms query.((("common terms query"))) +而在`match`查询高/低频词组是非常有用的,有时你想在高频词组和低频词组应如何处理((("stopwords", "low and high frequency terms", "more control over common terms")))更多的控制权利。该`match`查询公开的一个子集功能在((("common terms query"))) `common`词条查询中可用。 -For instance, we could make all low-frequency terms required, and score only -documents that have 75% of all high-frequency terms with a query like this: +例如,我们查询所有的低频词条都是必须的,并且评分高于75%的所有高频词条比如以下查询: [source,json] --------------------------------- @@ -188,5 +155,5 @@ documents that have 75% of all high-frequency terms with a query like this: } --------------------------------- -See the {ref}/query-dsl-common-terms-query.html[`common` terms query] reference page for more options. +查看更多的其他选择项,请参考相关页面{ref}/query-dsl-common-terms-query.html[`common` terms query]。 From 067152e4d54c8097981cfbfc70d845c7f477e860 Mon Sep 17 00:00:00 2001 From: "hua.chen" Date: Tue, 23 Aug 2016 15:28:04 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=E8=87=AA=E5=B7=B1=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E7=BF=BB=E8=AF=91=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 240_Stopwords/40_Divide_and_conquer.asciidoc | 46 ++++++++++---------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/240_Stopwords/40_Divide_and_conquer.asciidoc b/240_Stopwords/40_Divide_and_conquer.asciidoc index 031f19d6d..6266285f0 100644 --- a/240_Stopwords/40_Divide_and_conquer.asciidoc +++ b/240_Stopwords/40_Divide_and_conquer.asciidoc @@ -1,21 +1,19 @@ [[common-terms]] -=== 词条区分管理 +=== 词项的分别管理(Divide and Conquer) -在查询字符串时,词条可以分为十分重要 (低频词) 和不太重要 (高频词) 。((("stopwords", "low and high frequency terms"))) 只匹配不太重要词条的文档,很可能是没有多少关联的文档. 然而,我们想 -尽可能多的比较重要的术语的匹配文档。 +在查询字符串中的词项可以分为更重要 (低频词) 和次重要 (高频词) 这两类。((("stopwords", "low and high frequency terms"))) 只与次重要词项匹配的文档很有可能不太相关。实际上,我们想要文档能尽可能多的匹配那些更重要的词项。 -此`match`查询接受一个((("cutoff_frequency parameter")))((("match query", "cutoff_frequency parameter")))`cutoff_frequency`参数,它允许在查询字符串的词条划分成低频和高频组。((("term frequency", "cutoff_frequency parameter in match query")))低频组(十分重要的术语)形成了大量的查询,而高频率组(不太重要的术语)只为用于评分计算,不匹配。通过区别对待这两组词条,我们可以 -对以前的慢查询获得速度上的提高作用。 +`match` 查询接受一个参数 ((("cutoff_frequency parameter")))((("match query", "cutoff_frequency parameter")))`cutoff_frequency`,从而可以让它将查询字符串里的词项分为低频和高频两组。((("term frequency", "cutoff_frequency parameter in match query")))低频组(更重要的词项)组成 `bulk` 大量查询条件,而高频组(次重要的词项)只会用来评分,而不参与匹配过程。通过对这两组词的区分处理,我们可以在之前慢查询的基础上获得巨大的速度提升。 -.特定领域停用词 +.领域相关的停用词(Domain-Specific Stopwords) ********************************************* - `cutoff_frequency` 配置的好处是,你在 _特定领域_ 使用停用词不受约束。((("domain specific stopwords")))((("stopwords", "domain specific")))例如,关于电影网站使用的词 _movie_,_color_,_black_和_white_ ,这些词往往可能认为几乎没有任何意义。使用 `stop` 词汇单元过滤器,这些特定领域的词条必须手动添加到停用词列表中。然而, `cutoff_frequency` 着眼于这些词条的实际频率指数,这些词条会被自动归类为 _高频词汇_。 + `cutoff_frequency` 配置的好处是,你在 _特定领域_ 使用停用词不受约束。((("domain specific stopwords")))((("stopwords", "domain specific")))例如,关于电影网站使用的词 _movie_,_color_,_black_和_white_ ,这些词我们往往认为几乎没有任何意义。使用 `stop` 词汇单元过滤器,这些特定领域的词必须手动添加到停用词列表中。然而, `cutoff_frequency` 会查看索引里词项的具体频率,这些词会被自动归类为 _高频词汇_。 ********************************************* -使用以下查询作为示例: +以下面查询为例: [source,json] --------------------------------- @@ -27,9 +25,9 @@ } } --------------------------------- -<1> 任何词条出现在文档中超过1%,被认为是高频率。`cutoff_frequency` 配置可以指定为一个分数(`0.01`)或者一个正整数(`5`)。 +<1> 任何词项出现在文档中超过1%,被认为是高频词。`cutoff_frequency` 配置可以指定为一个分数(`0.01`)或者一个正整数(`5`)。 -此查询通过`cutoff_frequency` 配置,将查询条件划分为低频率组 (`quick`, `dead`)和高频率组 (`and`, +此查询通过`cutoff_frequency` 配置,将查询条件划分为低频组 (`quick`, `dead`)和高频组 (`and`, `the`)。然后,此查询会被重写为以下的`bool` 查询: [source,json] @@ -55,22 +53,22 @@ } } --------------------------------- -<1> 必须匹配有一个低频且高重要性词条。 -<2> 高频/低重要性词条是完全可有可无。 +<1> 必须匹配至少一个低频/更重要的词项。 +<2> 高频/次重要性词项是非必须的。 -此处`must` 意味着低频率词汇—`quick` 或者 `dead`— 至少有一个匹配;必须存在一个词,此文档被认为是匹配的。所有其他的文档被排除在外。然后`should`子句查找高频词条 `and` 和 `the`,只是在`must` 子句查询的结果集文档中查询。 -`should`子句的唯一的工作就是文档中包含``Quick _and the_ dead''高于包含``_The_ quick but dead''的得分。这种做法大大减少需要进行检查的文档数目。  +`must` 意味着至少有一个低频词 —`quick` 或者 `dead`— 必须出现在被匹配文档中。所有其他的文档被排除在外。`should` 语句查找高频词 `and` 和 `the`,但也只是在`must` 语句查询的结果集文档中查询。 +`should`语句的唯一的工作就是在对如``Quick _and the_ dead''和``_The_ quick but dead''语句进行评分时,前者得分比后者高。这种方式可以大大减少需要进行评分计算的文档数量。 [TIP] ================================================== -设置操作参数为`and`,将使用所有低频词条都必须,得分较高是含有较多高频词条的文档。然而,匹配的文档中并不需要包含所有的高频词条。如果你希望所有的低频和高频词条都被指定为必须的。那么你应该使用`bool` 查询方式代替`match`查询。现在正如我们看到的<>,这个已经是一个很高效的查询。 +将操作符参数设置成 `and` 会要求所有低频词都必须匹配,同时对包含所有高频词的文档给予更高评分。但是,在匹配文档时,并不要求文档必须包含所有高频词,如果希望文档包含所有的低频和高频词,我们应该使用一个 `bool` 来替代。正如我们在 `and` 操作符(and Operator)<> 中看到的,它的查询效率已经很高了。 ================================================== ==== 控制精度 -`minimum_should_match`参数可用 `cutoff_frequency`组合使用,但是此参数仅适用与低频词条。((("stopwords", "low and high frequency terms", "controlling precision")))((("minimum_should_match parameter", "controlling precision")))如以下查询: +`minimum_should_match` 参数可以与 `cutoff_frequency` 组合使用,但是此参数仅适用与低频词。((("stopwords", "low and high frequency terms", "controlling precision")))((("minimum_should_match parameter", "controlling precision")))如以下查询: [source,json] --------------------------------- @@ -110,12 +108,12 @@ } } --------------------------------- -<1> 因为只有两个词,原来的75%向下取整为`1`,意思是:二分之一的低频词条必须匹配。 -<2> 高频词条仍可选的,并且仅用于评分使用。 +<1> 因为只有两个词,原来的75%向下取整为`1`,意思是:必须匹配低频词的两者之一。 +<2> 高频词仍可选的,并且仅用于评分使用。 -==== 高频词条 +==== 高频词 -仅查询 `or` 高频((("stopwords", "low and high frequency terms", "only high frequency terms")))词条,对—``To be, or not to be''— 词条来说性能太糟糕啦。查询所有文档返回评分最高的前10个。我们真正的意图是查询整个—``To be, or not to be''—词条出现的文档,所以在这种情况下,不存低频所言,这个查询需要重写为所有高频词条都必须: +当使用 `or` 查询高频词条((("stopwords", "low and high frequency terms", "only high frequency terms"))),如(``To be, or not to be'')进行查询时性能最差。只是为了返回最匹配的前十个结果就对只是包含这些词的所有文档进行评分是盲目的。我们真正的意图是查询整个 (``To be, or not to be'')词条出现的文档,所以在这种情况下,不存低频所言,这个查询需要重写为所有高频词条都必须: [source,json] --------------------------------- @@ -133,11 +131,11 @@ } --------------------------------- -==== 对普通词条更多的控制 +==== 对常用词使用更多控制(More Control with Common Terms) -而在`match`查询高/低频词组是非常有用的,有时你想在高频词组和低频词组应如何处理((("stopwords", "low and high frequency terms", "more control over common terms")))更多的控制权利。该`match`查询公开的一个子集功能在((("common terms query"))) `common`词条查询中可用。 +尽管高频/低频的功能在 `match` 查询中是有用的,有时我们还希望能对它((("stopwords", "low and high frequency terms", "more control over common terms")))有更多的控制,想控制它对高频和低频词分组的行为。 `match` 查询针对 ((("common terms query"))) `common` 词项查询提供了一组功能。 -例如,我们查询所有的低频词条都是必须的,并且评分高于75%的所有高频词条比如以下查询: +例如,我们可以让所有低频词都必须匹配,而只对那些包括超过 75% 的高频词文档进行评分: [source,json] --------------------------------- @@ -155,5 +153,5 @@ } --------------------------------- -查看更多的其他选择项,请参考相关页面{ref}/query-dsl-common-terms-query.html[`common` terms query]。 +更多配置项参见 {ref}/query-dsl-common-terms-query.html[`common` terms query]。 From bbbe9bedd628caa5900206eea87e1e67766f0dbc Mon Sep 17 00:00:00 2001 From: "hua.chen" Date: Wed, 24 Aug 2016 17:14:23 +0800 Subject: [PATCH 03/10] =?UTF-8?q?review=20=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 240_Stopwords/40_Divide_and_conquer.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/240_Stopwords/40_Divide_and_conquer.asciidoc b/240_Stopwords/40_Divide_and_conquer.asciidoc index 6266285f0..84c5f54df 100644 --- a/240_Stopwords/40_Divide_and_conquer.asciidoc +++ b/240_Stopwords/40_Divide_and_conquer.asciidoc @@ -62,7 +62,7 @@ [TIP] ================================================== -将操作符参数设置成 `and` 会要求所有低频词都必须匹配,同时对包含所有高频词的文档给予更高评分。但是,在匹配文档时,并不要求文档必须包含所有高频词,如果希望文档包含所有的低频和高频词,我们应该使用一个 `bool` 来替代。正如我们在 `and` 操作符(and Operator)<> 中看到的,它的查询效率已经很高了。 +将操作符参数设置成 `and` 会要求所有低频词都必须匹配,同时对包含所有高频词的文档给予更高评分。但是,在匹配文档时,并不要求文档必须包含所有高频词。如果希望文档包含所有的低频和高频词,我们应该使用一个 `bool` 来替代。正如我们在 `and` 操作符(and Operator)<> 中看到的,它的查询效率已经很高了。 ================================================== From 1ebc87c06fa48d6ce6ab8ff26b2c36ec04caf328 Mon Sep 17 00:00:00 2001 From: "hua.chen" Date: Mon, 14 Nov 2016 16:14:26 +0800 Subject: [PATCH 04/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BC=96=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 240_Stopwords/40_Divide_and_conquer.asciidoc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/240_Stopwords/40_Divide_and_conquer.asciidoc b/240_Stopwords/40_Divide_and_conquer.asciidoc index 84c5f54df..79b6fa1e7 100644 --- a/240_Stopwords/40_Divide_and_conquer.asciidoc +++ b/240_Stopwords/40_Divide_and_conquer.asciidoc @@ -6,10 +6,10 @@ `match` 查询接受一个参数 ((("cutoff_frequency parameter")))((("match query", "cutoff_frequency parameter")))`cutoff_frequency`,从而可以让它将查询字符串里的词项分为低频和高频两组。((("term frequency", "cutoff_frequency parameter in match query")))低频组(更重要的词项)组成 `bulk` 大量查询条件,而高频组(次重要的词项)只会用来评分,而不参与匹配过程。通过对这两组词的区分处理,我们可以在之前慢查询的基础上获得巨大的速度提升。 -.领域相关的停用词(Domain-Specific Stopwords) +领域相关的停用词(Domain-Specific Stopwords) ********************************************* - `cutoff_frequency` 配置的好处是,你在 _特定领域_ 使用停用词不受约束。((("domain specific stopwords")))((("stopwords", "domain specific")))例如,关于电影网站使用的词 _movie_,_color_,_black_和_white_ ,这些词我们往往认为几乎没有任何意义。使用 `stop` 词汇单元过滤器,这些特定领域的词必须手动添加到停用词列表中。然而, `cutoff_frequency` 会查看索引里词项的具体频率,这些词会被自动归类为 _高频词汇_。 +`cutoff_frequency` 配置的好处是,你在 _特定领域_ 使用停用词不受约束。((("domain specific stopwords")))((("stopwords", "domain specific")))例如,关于电影网站使用的词 _movie_ ,_color_ ,_black_ 和 _white_ ,这些词我们往往认为几乎没有任何意义。使用 `stop` 词汇单元过滤器,这些特定领域的词必须手动添加到停用词列表中。然而 `cutoff_frequency` 会查看索引里词项的具体频率,这些词会被自动归类为 _高频词汇_ 。 ********************************************* @@ -27,8 +27,7 @@ --------------------------------- <1> 任何词项出现在文档中超过1%,被认为是高频词。`cutoff_frequency` 配置可以指定为一个分数(`0.01`)或者一个正整数(`5`)。 -此查询通过`cutoff_frequency` 配置,将查询条件划分为低频组 (`quick`, `dead`)和高频组 (`and`, -`the`)。然后,此查询会被重写为以下的`bool` 查询: +此查询通过`cutoff_frequency` 配置,将查询条件划分为低频组 (`quick`, `dead`)和高频组 (`and`,`the`)。然后,此查询会被重写为以下的`bool` 查询: [source,json] --------------------------------- @@ -113,7 +112,7 @@ ==== 高频词 -当使用 `or` 查询高频词条((("stopwords", "low and high frequency terms", "only high frequency terms"))),如(``To be, or not to be'')进行查询时性能最差。只是为了返回最匹配的前十个结果就对只是包含这些词的所有文档进行评分是盲目的。我们真正的意图是查询整个 (``To be, or not to be'')词条出现的文档,所以在这种情况下,不存低频所言,这个查询需要重写为所有高频词条都必须: +当使用 `or` 查询高频词条((("stopwords", "low and high frequency terms", "only high frequency terms"))),如(—``To be, or not to be'')—进行查询时性能最差。只是为了返回最匹配的前十个结果就对只是包含这些词的所有文档进行评分是盲目的。我们真正的意图是查询整个—(``To be, or not to be'')—词条出现的文档,所以在这种情况下,不存低频所言,这个查询需要重写为所有高频词条都必须: [source,json] --------------------------------- From 95800d4c46c21135f4474e2246a4854856ccf842 Mon Sep 17 00:00:00 2001 From: "hua.chen" Date: Sun, 4 Dec 2016 22:11:16 +0800 Subject: [PATCH 05/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 240_Stopwords/40_Divide_and_conquer.asciidoc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/240_Stopwords/40_Divide_and_conquer.asciidoc b/240_Stopwords/40_Divide_and_conquer.asciidoc index 79b6fa1e7..2e0a3599d 100644 --- a/240_Stopwords/40_Divide_and_conquer.asciidoc +++ b/240_Stopwords/40_Divide_and_conquer.asciidoc @@ -4,7 +4,7 @@ 在查询字符串中的词项可以分为更重要 (低频词) 和次重要 (高频词) 这两类。((("stopwords", "low and high frequency terms"))) 只与次重要词项匹配的文档很有可能不太相关。实际上,我们想要文档能尽可能多的匹配那些更重要的词项。 -`match` 查询接受一个参数 ((("cutoff_frequency parameter")))((("match query", "cutoff_frequency parameter")))`cutoff_frequency`,从而可以让它将查询字符串里的词项分为低频和高频两组。((("term frequency", "cutoff_frequency parameter in match query")))低频组(更重要的词项)组成 `bulk` 大量查询条件,而高频组(次重要的词项)只会用来评分,而不参与匹配过程。通过对这两组词的区分处理,我们可以在之前慢查询的基础上获得巨大的速度提升。 +`match` 查询接受一个参数 ((("cutoff_frequency parameter")))((("match query", "cutoff_frequency parameter")))`cutoff_frequency` ,从而可以让它将查询字符串里的词项分为低频和高频两组。((("term frequency", "cutoff_frequency parameter in match query")))低频组(更重要的词项)组成 `bulk` 大量查询条件,而高频组(次重要的词项)只会用来评分,而不参与匹配过程。通过对这两组词的区分处理,我们可以在之前慢查询的基础上获得巨大的速度提升。 领域相关的停用词(Domain-Specific Stopwords) ********************************************* @@ -55,7 +55,7 @@ <1> 必须匹配至少一个低频/更重要的词项。 <2> 高频/次重要性词项是非必须的。 -`must` 意味着至少有一个低频词 —`quick` 或者 `dead`— 必须出现在被匹配文档中。所有其他的文档被排除在外。`should` 语句查找高频词 `and` 和 `the`,但也只是在`must` 语句查询的结果集文档中查询。 +`must` 意味着至少有一个低频词 — `quick` 或者 `dead` — 必须出现在被匹配文档中。所有其他的文档被排除在外。`should` 语句查找高频词 `and` 和 `the`,但也只是在`must` 语句查询的结果集文档中查询。 `should`语句的唯一的工作就是在对如``Quick _and the_ dead''和``_The_ quick but dead''语句进行评分时,前者得分比后者高。这种方式可以大大减少需要进行评分计算的文档数量。 [TIP] @@ -66,8 +66,7 @@ ================================================== ==== 控制精度 - -`minimum_should_match` 参数可以与 `cutoff_frequency` 组合使用,但是此参数仅适用与低频词。((("stopwords", "low and high frequency terms", "controlling precision")))((("minimum_should_match parameter", "controlling precision")))如以下查询: +`minimum_should_match` 参数可以与 `cutoff_frequency` 组合使用,但是此参数仅适用与低频词。((("stopwords", "low and high frequency terms", "controlling precision")))((("minimum_should_match parameter", "controlling precision")))如以下查询: [source,json] --------------------------------- From 8d3c9889615fdc600661d5d496c269b8c1c54763 Mon Sep 17 00:00:00 2001 From: "hua.chen" Date: Sun, 4 Dec 2016 22:18:50 +0800 Subject: [PATCH 06/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 240_Stopwords/40_Divide_and_conquer.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/240_Stopwords/40_Divide_and_conquer.asciidoc b/240_Stopwords/40_Divide_and_conquer.asciidoc index 2e0a3599d..048c7c4c0 100644 --- a/240_Stopwords/40_Divide_and_conquer.asciidoc +++ b/240_Stopwords/40_Divide_and_conquer.asciidoc @@ -55,7 +55,7 @@ <1> 必须匹配至少一个低频/更重要的词项。 <2> 高频/次重要性词项是非必须的。 -`must` 意味着至少有一个低频词 — `quick` 或者 `dead` — 必须出现在被匹配文档中。所有其他的文档被排除在外。`should` 语句查找高频词 `and` 和 `the`,但也只是在`must` 语句查询的结果集文档中查询。 +`must` 意味着至少有一个低频词 —`quick` 或者 `dead` —须出现在被匹配文档中。所有其他的文档被排除在外。`should` 语句查找高频词 `and` 和 `the`,但也只是在`must` 语句查询的结果集文档中查询。 `should`语句的唯一的工作就是在对如``Quick _and the_ dead''和``_The_ quick but dead''语句进行评分时,前者得分比后者高。这种方式可以大大减少需要进行评分计算的文档数量。 [TIP] From e990be7a90ff7d7bf85541da86ca33293053df4d Mon Sep 17 00:00:00 2001 From: "hua.chen" Date: Sun, 4 Dec 2016 22:44:43 +0800 Subject: [PATCH 07/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 240_Stopwords/40_Divide_and_conquer.asciidoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/240_Stopwords/40_Divide_and_conquer.asciidoc b/240_Stopwords/40_Divide_and_conquer.asciidoc index 048c7c4c0..f88c19ec6 100644 --- a/240_Stopwords/40_Divide_and_conquer.asciidoc +++ b/240_Stopwords/40_Divide_and_conquer.asciidoc @@ -55,8 +55,8 @@ <1> 必须匹配至少一个低频/更重要的词项。 <2> 高频/次重要性词项是非必须的。 -`must` 意味着至少有一个低频词 —`quick` 或者 `dead` —须出现在被匹配文档中。所有其他的文档被排除在外。`should` 语句查找高频词 `and` 和 `the`,但也只是在`must` 语句查询的结果集文档中查询。 -`should`语句的唯一的工作就是在对如``Quick _and the_ dead''和``_The_ quick but dead''语句进行评分时,前者得分比后者高。这种方式可以大大减少需要进行评分计算的文档数量。 +`must` 意味着至少有一个低频词 -`quick` 或者 `dead`- 须出现在被匹配文档中。所有其他的文档被排除在外。`should` 语句查找高频词 `and` 和 `the`,但也只是在`must` 语句查询的结果集文档中查询。 +`should`语句的唯一的工作就是在对如``Quick _and the_ dead``和``_The_ quick but dead``语句进行评分时,前者得分比后者高。这种方式可以大大减少需要进行评分计算的文档数量。 [TIP] ================================================== @@ -111,7 +111,7 @@ ==== 高频词 -当使用 `or` 查询高频词条((("stopwords", "low and high frequency terms", "only high frequency terms"))),如(—``To be, or not to be'')—进行查询时性能最差。只是为了返回最匹配的前十个结果就对只是包含这些词的所有文档进行评分是盲目的。我们真正的意图是查询整个—(``To be, or not to be'')—词条出现的文档,所以在这种情况下,不存低频所言,这个查询需要重写为所有高频词条都必须: +当使用 `or` 查询高频词条((("stopwords", "low and high frequency terms", "only high frequency terms"))),如—``To be, or not to be``-进行查询时性能最差。只是为了返回最匹配的前十个结果就对只是包含这些词的所有文档进行评分是盲目的。我们真正的意图是查询整个—''To be, or not to be''—词条出现的文档,所以在这种情况下,不存低频所言,这个查询需要重写为所有高频词条都必须: [source,json] --------------------------------- From d86345a4fc6627d6351af802ddcd016ecf0e36b8 Mon Sep 17 00:00:00 2001 From: "hua.chen" Date: Sun, 4 Dec 2016 22:50:38 +0800 Subject: [PATCH 08/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 240_Stopwords/40_Divide_and_conquer.asciidoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/240_Stopwords/40_Divide_and_conquer.asciidoc b/240_Stopwords/40_Divide_and_conquer.asciidoc index f88c19ec6..9955dd241 100644 --- a/240_Stopwords/40_Divide_and_conquer.asciidoc +++ b/240_Stopwords/40_Divide_and_conquer.asciidoc @@ -55,8 +55,8 @@ <1> 必须匹配至少一个低频/更重要的词项。 <2> 高频/次重要性词项是非必须的。 -`must` 意味着至少有一个低频词 -`quick` 或者 `dead`- 须出现在被匹配文档中。所有其他的文档被排除在外。`should` 语句查找高频词 `and` 和 `the`,但也只是在`must` 语句查询的结果集文档中查询。 -`should`语句的唯一的工作就是在对如``Quick _and the_ dead``和``_The_ quick but dead``语句进行评分时,前者得分比后者高。这种方式可以大大减少需要进行评分计算的文档数量。 +`must` 意味着至少有一个低频词— `quick` 或者 `dead` —必须出现在被匹配文档中。所有其他的文档被排除在外。`should` 语句查找高频词 `and` 和 `the`,但也只是在 `must` 语句查询的结果集文档中查询。 + `should` 语句的唯一的工作就是在对如 `Quick _and the_ dead` 和 `_The_ quick but dead` 语句进行评分时,前者得分比后者高。这种方式可以大大减少需要进行评分计算的文档数量。 [TIP] ================================================== @@ -111,7 +111,7 @@ ==== 高频词 -当使用 `or` 查询高频词条((("stopwords", "low and high frequency terms", "only high frequency terms"))),如—``To be, or not to be``-进行查询时性能最差。只是为了返回最匹配的前十个结果就对只是包含这些词的所有文档进行评分是盲目的。我们真正的意图是查询整个—''To be, or not to be''—词条出现的文档,所以在这种情况下,不存低频所言,这个查询需要重写为所有高频词条都必须: +当使用 `or` 查询高频词条((("stopwords", "low and high frequency terms", "only high frequency terms"))),如— `To be, or not to be` —进行查询时性能最差。只是为了返回最匹配的前十个结果就对只是包含这些词的所有文档进行评分是盲目的。我们真正的意图是查询整个词条出现的文档,所以在这种情况下,不存低频所言,这个查询需要重写为所有高频词条都必须: [source,json] --------------------------------- From 478cd2bbbe2bca69af18901b243358369a15d2b6 Mon Sep 17 00:00:00 2001 From: "hua.chen" Date: Sun, 4 Dec 2016 23:21:29 +0800 Subject: [PATCH 09/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 240_Stopwords/40_Divide_and_conquer.asciidoc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/240_Stopwords/40_Divide_and_conquer.asciidoc b/240_Stopwords/40_Divide_and_conquer.asciidoc index 9955dd241..5a779cd51 100644 --- a/240_Stopwords/40_Divide_and_conquer.asciidoc +++ b/240_Stopwords/40_Divide_and_conquer.asciidoc @@ -1,7 +1,7 @@ [[common-terms]] === 词项的分别管理(Divide and Conquer) -在查询字符串中的词项可以分为更重要 (低频词) 和次重要 (高频词) 这两类。((("stopwords", "low and high frequency terms"))) 只与次重要词项匹配的文档很有可能不太相关。实际上,我们想要文档能尽可能多的匹配那些更重要的词项。 +在查询字符串中的词项可以分为更重要(低频词)和次重要(高频词)这两类。((("stopwords", "low and high frequency terms"))) 只与次重要词项匹配的文档很有可能不太相关。实际上,我们想要文档能尽可能多的匹配那些更重要的词项。 `match` 查询接受一个参数 ((("cutoff_frequency parameter")))((("match query", "cutoff_frequency parameter")))`cutoff_frequency` ,从而可以让它将查询字符串里的词项分为低频和高频两组。((("term frequency", "cutoff_frequency parameter in match query")))低频组(更重要的词项)组成 `bulk` 大量查询条件,而高频组(次重要的词项)只会用来评分,而不参与匹配过程。通过对这两组词的区分处理,我们可以在之前慢查询的基础上获得巨大的速度提升。 @@ -9,11 +9,11 @@ 领域相关的停用词(Domain-Specific Stopwords) ********************************************* -`cutoff_frequency` 配置的好处是,你在 _特定领域_ 使用停用词不受约束。((("domain specific stopwords")))((("stopwords", "domain specific")))例如,关于电影网站使用的词 _movie_ ,_color_ ,_black_ 和 _white_ ,这些词我们往往认为几乎没有任何意义。使用 `stop` 词汇单元过滤器,这些特定领域的词必须手动添加到停用词列表中。然而 `cutoff_frequency` 会查看索引里词项的具体频率,这些词会被自动归类为 _高频词汇_ 。 +`cutoff_frequency` 配置的好处是,你在 _特定领域_ 使用停用词不受约束。((("domain specific stopwords")))((("stopwords", "domain specific")))例如,关于电影网站使用的词 _movie_ 、 _color_ 、 _black_ 和 _white_ ,这些词我们往往认为几乎没有任何意义。使用 `stop` 词汇单元过滤器,这些特定领域的词必须手动添加到停用词列表中。然而 `cutoff_frequency` 会查看索引里词项的具体频率,这些词会被自动归类为 _高频词汇_ 。 ********************************************* -以下面查询为例: +以下面查询为例: [source,json] --------------------------------- @@ -25,9 +25,9 @@ } } --------------------------------- -<1> 任何词项出现在文档中超过1%,被认为是高频词。`cutoff_frequency` 配置可以指定为一个分数(`0.01`)或者一个正整数(`5`)。 +<1> 任何词项出现在文档中超过1%,被认为是高频词。`cutoff_frequency` 配置可以指定为一个分数(`0.01`)或者一个正整数(`5`)。 -此查询通过`cutoff_frequency` 配置,将查询条件划分为低频组 (`quick`, `dead`)和高频组 (`and`,`the`)。然后,此查询会被重写为以下的`bool` 查询: +此查询通过`cutoff_frequency` 配置,将查询条件划分为低频组(`quick`, `dead`)和高频组(`and`,`the`)。然后,此查询会被重写为以下的`bool` 查询: [source,json] --------------------------------- @@ -61,7 +61,7 @@ [TIP] ================================================== -将操作符参数设置成 `and` 会要求所有低频词都必须匹配,同时对包含所有高频词的文档给予更高评分。但是,在匹配文档时,并不要求文档必须包含所有高频词。如果希望文档包含所有的低频和高频词,我们应该使用一个 `bool` 来替代。正如我们在 `and` 操作符(and Operator)<> 中看到的,它的查询效率已经很高了。 +将操作符参数设置成 `and` 会要求所有低频词都必须匹配,同时对包含所有高频词的文档给予更高评分。但是,在匹配文档时,并不要求文档必须包含所有高频词。如果希望文档包含所有的低频和高频词,我们应该使用一个 `bool` 来替代。正如我们在<>中看到的,它的查询效率已经很高了。 ================================================== @@ -106,7 +106,7 @@ } } --------------------------------- -<1> 因为只有两个词,原来的75%向下取整为`1`,意思是:必须匹配低频词的两者之一。 +<1> 因为只有两个词,原来的75%向下取整为 `1` ,意思是:必须匹配低频词的两者之一。 <2> 高频词仍可选的,并且仅用于评分使用。 ==== 高频词 From 9b12fa0d870ca32679afaf26bbf5d0d97ac2a62f Mon Sep 17 00:00:00 2001 From: chenhuaa Date: Fri, 6 Jan 2017 09:29:12 +0800 Subject: [PATCH 10/10] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 240_Stopwords/40_Divide_and_conquer.asciidoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/240_Stopwords/40_Divide_and_conquer.asciidoc b/240_Stopwords/40_Divide_and_conquer.asciidoc index 5a779cd51..8c9a504d8 100644 --- a/240_Stopwords/40_Divide_and_conquer.asciidoc +++ b/240_Stopwords/40_Divide_and_conquer.asciidoc @@ -25,9 +25,9 @@ } } --------------------------------- -<1> 任何词项出现在文档中超过1%,被认为是高频词。`cutoff_frequency` 配置可以指定为一个分数(`0.01`)或者一个正整数(`5`)。 +<1> 任何词项出现在文档中超过1%,被认为是高频词。`cutoff_frequency` 配置可以指定为一个分数( `0.01` )或者一个正整数( `5` )。 -此查询通过`cutoff_frequency` 配置,将查询条件划分为低频组(`quick`, `dead`)和高频组(`and`,`the`)。然后,此查询会被重写为以下的`bool` 查询: +此查询通过 `cutoff_frequency` 配置,将查询条件划分为低频组( `quick` , `dead` )和高频组( `and` , `the` )。然后,此查询会被重写为以下的 `bool` 查询: [source,json] --------------------------------- @@ -55,7 +55,7 @@ <1> 必须匹配至少一个低频/更重要的词项。 <2> 高频/次重要性词项是非必须的。 -`must` 意味着至少有一个低频词— `quick` 或者 `dead` —必须出现在被匹配文档中。所有其他的文档被排除在外。`should` 语句查找高频词 `and` 和 `the`,但也只是在 `must` 语句查询的结果集文档中查询。 +`must` 意味着至少有一个低频词— `quick` 或者 `dead` —必须出现在被匹配文档中。所有其他的文档被排除在外。 `should` 语句查找高频词 `and` 和 `the` ,但也只是在 `must` 语句查询的结果集文档中查询。 `should` 语句的唯一的工作就是在对如 `Quick _and the_ dead` 和 `_The_ quick but dead` 语句进行评分时,前者得分比后者高。这种方式可以大大减少需要进行评分计算的文档数量。 [TIP]