Skip to content

Commit

Permalink
Fix the explanation of "coord" in the bool query.
Browse files Browse the repository at this point in the history
  • Loading branch information
clintongormley committed May 14, 2014
1 parent 46447f0 commit c1052c7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
12 changes: 6 additions & 6 deletions 110_Multi_Field_Search/05_Multiple_query_strings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 4 additions & 3 deletions 110_Multi_Field_Search/15_Best_field.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit c1052c7

Please sign in to comment.