You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Qi Li <al...@gmail.com> on 2010/09/21 22:19:42 UTC

How to calculate the fieldNorm

Hi, guys:

I read this  http://lucene.apache.org/java/3_0_2/api/core/index.html . But I
am confused about how the fieldNorm is calculated after seeing the
explanation.

( I am using StandardAnalyzer for both index and search)
*1.. Index Part*
     document 0:
           doc.add(new Field("test","it's time to pay income tax",
Field.Store.YES, Field.Index.Analyzed));
           doc.add(new Field("test","return library books on time",
Field.Store.YES, Field.Index.Analyzed));

     document 1:
          doc.add(new Field("test","it's time to pay income tax return
library books on time", Field.Store.YES, Field.Index.Analyzed));

*2.  Search Part*
        QueryParser parser = new QueryParser(Version.LUCENE_30,
"test",standard);
        Query query = parser.parse("tax return");
       TopDocs hits = searcher.search(query, 10);

*3.  Result with explanation*

*document id: 0*
score : 26.905577
26.905577 = (MATCH) sum of:
  13.452788 = (MATCH) weight(major:tax in 0), product of:
    0.70710677 = queryWeight(major:tax), product of:
      0.5945349 = idf(docFreq=2, maxDocs=2)
      1.1893445 = queryNorm
    19.025116 = (MATCH) fieldWeight(major:tax in 0), product of:
      1.0 = tf(termFreq(major:tax)=1)
      0.5945349 = idf(docFreq=2, maxDocs=2)
*      32.0 = fieldNorm(field=major, doc=0)*
  13.452788 = (MATCH) weight(major:return in 0), product of:
    0.70710677 = queryWeight(major:return), product of:
      0.5945349 = idf(docFreq=2, maxDocs=2)
      1.1893445 = queryNorm
    19.025116 = (MATCH) fieldWeight(major:return in 0), product of:
      1.0 = tf(termFreq(major:return)=1)
      0.5945349 = idf(docFreq=2, maxDocs=2)
   *   32.0 = fieldNorm(field=major, doc=0)*

*document id: 1*
score : 0.31529972
0.31529972 = (MATCH) sum of:
  0.15764986 = (MATCH) weight(major:tax in 1), product of:
    0.70710677 = queryWeight(major:tax), product of:
      0.5945349 = idf(docFreq=2, maxDocs=2)
      1.1893445 = queryNorm
    0.22295058 = (MATCH) fieldWeight(major:tax in 1), product of:
      1.0 = tf(termFreq(major:tax)=1)
      0.5945349 = idf(docFreq=2, maxDocs=2)
      *0.375 = fieldNorm(field=major, doc=1)*
  0.15764986 = (MATCH) weight(major:return in 1), product of:
    0.70710677 = queryWeight(major:return), product of:
      0.5945349 = idf(docFreq=2, maxDocs=2)
      1.1893445 = queryNorm
    0.22295058 = (MATCH) fieldWeight(major:return in 1), product of:
      1.0 = tf(termFreq(major:return)=1)
      0.5945349 = idf(docFreq=2, maxDocs=2)
      *0.375 = fieldNorm(field=major, doc=1)*


*4. Questions:*
   1.  why the the value of fieldNorm is so different ?  (32.0   vs 0.375)
.
   2.  Anybody knows how to calculate the fieldNorm for this case by hand?

Thank you very much.

Best regards,
Qi Li