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 liquideshark <ta...@gmail.com> on 2007/02/01 12:15:49 UTC

problem with field.setboost(5.0f) on lucene 2.00

iam building up a search engine using lucene 2.0, and iam having problem
using the term boost "setboost" a part of my code is :
and my code is :

doc.add(new
Field("title",httpd.getTitle(),Field.Store.YES,Field.Index.TOKENIZED ));
doc.getField("title").setboost(5.0f);//  <=== the boost wont update to 5.0
it remain 1.0
writer.addDocument(doc);
writer.optimize();
writer.close();

but when i look up in the index created the field title is still 1.0
can some one help me thx
-- 
View this message in context: http://www.nabble.com/problem-with-field.setboost%285.0f%29-on-lucene-2.00-tf3154250.html#a8746530
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


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


Re: problem with field.setboost(5.0f) on lucene 2.00

Posted by Chris Hostetter <ho...@fucit.org>.
: it still dont make any change on the boost value, for information i use
: luke.jar to see if the value had change

i'm not sure what you mean you're using luke to see if hte value has
changed ... boosts aren't stored in the index (they are used to compute a
fieldNorm) so there's nothing for luke to show you (but i haven't played
with luke extensively so i'm not sure what you might be looking at that
relates to boosts)

please note the javadocs for setBoost and getBoost...

public void setBoost(float boost)

    Sets the boost factor hits on this field. This value will be
multiplied into the score of all hits on this this field of this document.

    The boost is multiplied by Document.getBoost() of the document
containing this field. If a document has multiple fields with the same
name, all such values are multiplied together. This product is then
multipled by the value Similarity.lengthNorm(String,int), and rounded by
Similarity.encodeNorm(float) before it is stored in the index. One should
attempt to ensure that this product does not overflow the range of that
encoding.

public float getBoost()

    Returns the boost factor for hits for this field.

    The default value is 1.0.

    Note: this value is not stored directly with the document in the
index. Documents returned from IndexReader.document(int) and Hits.doc(int)
may thus not have the same value present as when this field was indexed.



-Hoss


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


Re: problem with field.setboost(5.0f) on lucene 2.00

Posted by liquideshark <ta...@gmail.com>.
Yes you are right 
but i have change it to:
------------------------------------------------
        Field tiTle = new
Field("title",httpd.getTitle(),Field.Store.YES,Field.Index.TOKENIZED );
        tiTle.setBoost(6.1f);
        doc.add(tiTle);
-----------------------------------------------
it still dont make any change on the boost value, for information i use
luke.jar to see if the value had change

nice reading you again
      Tandina






Erick Erickson wrote:
> 
> I haven't played with boosts, but I suspect your ordering is wrong. You've
> already added the field to the document before you set the boost. Try
> Field f = new Field()...
> 
> f.setBoost()
> 
> doc.add(f).
> 
> writer.addDoc(doc)..
> 
> Best
> Erick
> 
> On 2/1/07, liquideshark <ta...@gmail.com> wrote:
>>
>>
>> iam building up a search engine using lucene 2.0, and iam having problem
>> using the term boost "setboost" a part of my code is :
>> and my code is :
>>
>> doc.add(new
>> Field("title",httpd.getTitle(),Field.Store.YES,Field.Index.TOKENIZED ));
>> doc.getField("title").setboost(5.0f);//  <=== the boost wont update to
>> 5.0
>> it remain 1.0
>> writer.addDocument(doc);
>> writer.optimize();
>> writer.close();
>>
>> but when i look up in the index created the field title is still 1.0
>> can some one help me thx
>> --
>> View this message in context:
>> http://www.nabble.com/problem-with-field.setboost%285.0f%29-on-lucene-2.00-tf3154250.html#a8746530
>> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/problem-with-field.setboost%285.0f%29-on-lucene-2.00-tf3154250.html#a8748508
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


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


Re: problem with field.setboost(5.0f) on lucene 2.00

Posted by Erick Erickson <er...@gmail.com>.
I haven't played with boosts, but I suspect your ordering is wrong. You've
already added the field to the document before you set the boost. Try
Field f = new Field()...

f.setBoost()

doc.add(f).

writer.addDoc(doc)..

Best
Erick

On 2/1/07, liquideshark <ta...@gmail.com> wrote:
>
>
> iam building up a search engine using lucene 2.0, and iam having problem
> using the term boost "setboost" a part of my code is :
> and my code is :
>
> doc.add(new
> Field("title",httpd.getTitle(),Field.Store.YES,Field.Index.TOKENIZED ));
> doc.getField("title").setboost(5.0f);//  <=== the boost wont update to 5.0
> it remain 1.0
> writer.addDocument(doc);
> writer.optimize();
> writer.close();
>
> but when i look up in the index created the field title is still 1.0
> can some one help me thx
> --
> View this message in context:
> http://www.nabble.com/problem-with-field.setboost%285.0f%29-on-lucene-2.00-tf3154250.html#a8746530
> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>