lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bastian Grimm [Eastbeam GmbH]" ...@eastbeam.com>
Subject problem with get/setBoost of document fields
Date Wed, 22 Sep 2004 16:44:31 GMT
hi all,

i have a strange problem with the get and setBoost functions 
(lucene-1.4.1). i am trying the following code:

[...]
Document d1 = new Document();
Field f1 = Field.Text("field", "word");
f1.setBoost(2.0f);
d1.add(f1);
d1.setBoost(3.0f);
writer.addDocument(d1);
[...]

so if i'am right, this must be an overall boostfaktor of 6.0f for the 
doc...
if i try to get these boosts with:

[...]
Document doc = hits.doc(x);
System.out.println(doc.getField("field").getBoost());
System.out.println(doc.getBoost());
[...]

1.0 is returned in both cases. i dont really know what's wrong. i also 
tried some other types of Field.XXX , but nothing changed.

Another strange beheaviour is that:

[...]
    final float[] scores = new float[1];
    new IndexSearcher(store).search
      (new TermQuery(new Term("field", "word")),
       new HitCollector() {
         public final void collect(int doc, float score) {
           scores[doc] = score;
         }
       });
       for (int i = 0; i < 1; i++) {
        System.out.println(scores[i]);
    }
[...]

This function returns different scores if the boosts are changed but why 
aren't these boosts displayed correctly? any ideas?

if i set the d1 and f1 boost  to 1.0f (default) the score returned by 
the HitCollector is 0.3xxx - shouldn't it be exactly 1.0 ?


thanks for your time and kind regards from germany.
bastian


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Mime
View raw message