elasticsearch/elasticsearch-definitive-guide — pull request #280 by timothyperisho (2014-12-12 22:42:27+00:00)
Title: Corrected values in "Putting it Together" Example

The calculated values of the idf and fieldnorm were wrong according to the formulas given earlier in the document. I don't know whether this represents an error in the formulas, the setup of the example, or the calculations, but it is confusing for someone trying to learn es.

My Reasoning:
idf(docFreq=1, maxDocs=1)
= 1 + log ( numDocs / (docFreq + 1)) #Quoted from earlier in document
= 1 + log( maxDocs / (docFreq + 1) #Since maxDocs is the same as numDocs in this example, right?
= 1 + log( 1 / (1 + 1)) #plugging in the values
= 1 + log( 1/2)
= 1 + (-0.30102999566) #https://www.google.com/search?q=log%280.5%29&ie=utf-8&oe=utf-8#q=log%281%2F2%29
= 0.69897000 #rounded to 8 digits as in the current document

The number in the original document (0.30102999566) is the log(2). Maybe they flipped numDocs and docFreq and then forgot to add 1? idk.

fieldNorm(doc=0)
= 1 / sqrt(numTerms) #Quoted from earlier in document
= 1 / sqrt(3) #There are 3 terms: "quick", "brown", and "fox"
= 1 / 1.73205080757 #https://www.google.com/search?q=sqrt%283%29&ie=utf-8&oe=utf-8
= 0.57735027 #rounded to 8 digits to match idf precision

Perhaps there were supposed to be four terms in the example or perhaps the formula was supposed to be 1 / sqrt( 1 + numTerms ). Again, idk.