From c1052c7355afbbedcf0423bcaaf40e682d4a686f Mon Sep 17 00:00:00 2001 From: Clinton Gormley Date: Wed, 14 May 2014 10:29:23 +0200 Subject: [PATCH] Fix the explanation of "coord" in the bool query. --- .../05_Multiple_query_strings.asciidoc | 12 ++++++------ 110_Multi_Field_Search/15_Best_field.asciidoc | 7 ++++--- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/110_Multi_Field_Search/05_Multiple_query_strings.asciidoc b/110_Multi_Field_Search/05_Multiple_query_strings.asciidoc index c6d3ea76d..2c9c03920 100644 --- a/110_Multi_Field_Search/05_Multiple_query_strings.asciidoc +++ b/110_Multi_Field_Search/05_Multiple_query_strings.asciidoc @@ -61,12 +61,12 @@ Why did we put the translator clauses inside a separate `bool` query? All four clauses at the same level as the title and author clauses? The answer lies in how the score is calculated. The `bool` query runs each -`match` query, adds their scores together then divides by the number of -clauses. Each clause at the same level has the same weight. In the above -query, the `bool` query containing the translator clauses counts for ⅓ of -the total score. If we had put the translator clauses at the same level as -title and author, then they would have reduced the contribution of the title -and author clauses to ¼ each. +`match` query, adds their scores together, then multiplies by the number of +matching clauses, and divides by the total number of clauses. Each clause at +the same level has the same weight. In the above query, the `bool` query +containing the translator clauses counts for ⅓ of the total score. If we had +put the translator clauses at the same level as title and author, then they +would have reduced the contribution of the title and author clauses to ¼ each. ==== Prioritising clauses diff --git a/110_Multi_Field_Search/15_Best_field.asciidoc b/110_Multi_Field_Search/15_Best_field.asciidoc index f9ac08aa8..08a7b2642 100644 --- a/110_Multi_Field_Search/15_Best_field.asciidoc +++ b/110_Multi_Field_Search/15_Best_field.asciidoc @@ -71,14 +71,15 @@ And we find that this query actually gives Document 1 the higher score: To understand why, think about how the `bool` query calculates its score: * First, it runs both of the queries in the `should` clause -* then it adds their scores together -* and divides the total by the number of clauses, ie two. +* then it adds their scores together, +* multiplies the total by the number of matching clauses, +* and divides the result by the total number of clauses, ie two. Document 1 contains the word `"brown"` in both fields, so both `match` clauses are successful and have a score. Document 2 contains both `"brown"` and `"fox"` in the `body` field but neither word in the `title` field. The high score from the `body` query is added to the zero score from the `title` query, -and divided by two, resulting in a lower overall score than for Document 1. +and multiplied by ½, resulting in a lower overall score than for Document 1. In this example, the `title` and `body` fields are competing with each other. We want to find the single *best-matching* field.