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 jreeman <mi...@hotmail.com> on 2007/03/02 14:49:23 UTC

Re: [ANN] Overriding Similarity

Hello

The original message explaining why I wanted to overide DefaultSimilarity is
here :

http://www.nabble.com/forum/ViewPost.jtp?post=9268781&framed=y
http://www.nabble.com/forum/ViewPost.jtp?post=9268781&framed=y 

Si I overided DefaultSimilarity like this :

package org.apache.lenya.lucene.index;

import org.apache.lucene.search.DefaultSimilarity;

public class PersonalSimilarity extends DefaultSimilarity {
        public float idf(int docFreq, int numDocs)
        {
                return 1;
        }

}

And I use it like this :

PersonalSimilarity ds = new PersonalSimilarity();
searcher.setSimilarity(ds);

After that, all the hit have the same score.

But my new question is : do I need to use this PersonalSimilarity for the
IndexWriter because currently it yet works fine only in the Searcher.

-- 
View this message in context: http://www.nabble.com/Overriding-Similarity-tf2128934.html#a9269838
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: [ANN] Overriding Similarity

Posted by jreeman <mi...@hotmail.com>.
> If you modify all scores to 100%, why can't you just ignore them?
Because in this case only, the scores will be all 100% but in other case
not. The fact is I don't want the the score depends on the frequency. I
don't want this "smart" feature.

> Anyhow, if all you want to modify is idf(), using the modified similarity
class only at search time is ok. For further pointers and explanations take
a look at http://lucene.apache.org/java/docs/scoring.html

thanks a lot.
-- 
View this message in context: http://www.nabble.com/Overriding-Similarity-tf2128934.html#a9281357
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: [ANN] Overriding Similarity

Posted by Doron Cohen <DO...@il.ibm.com>.
If you modify all scores to 100%, why can't you just ignore them?

Anyhow, if all you want to modify is idf(), using the modified similarity
class only at search time is ok. For further pointers and explanations take
a look at http://lucene.apache.org/java/docs/scoring.html

Regards,
Doron

jreeman <mi...@hotmail.com> wrote on 02/03/2007 05:49:23:

>
> Hello
>
> The original message explaining why I wanted to overide DefaultSimilarity
is
> here :
>
> http://www.nabble.com/forum/ViewPost.jtp?post=9268781&framed=y
> http://www.nabble.com/forum/ViewPost.jtp?post=9268781&framed=y
>
> Si I overided DefaultSimilarity like this :
>
> package org.apache.lenya.lucene.index;
>
> import org.apache.lucene.search.DefaultSimilarity;
>
> public class PersonalSimilarity extends DefaultSimilarity {
>         public float idf(int docFreq, int numDocs)
>         {
>                 return 1;
>         }
>
> }
>
> And I use it like this :
>
> PersonalSimilarity ds = new PersonalSimilarity();
> searcher.setSimilarity(ds);
>
> After that, all the hit have the same score.
>
> But my new question is : do I need to use this PersonalSimilarity for the
> IndexWriter because currently it yet works fine only in the Searcher.
>
> --
> View this message in context: http://www.nabble.com/Overriding-
> Similarity-tf2128934.html#a9269838
> 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
>


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