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 Chris Salem <ch...@mainsequence.net> on 2009/08/19 22:20:07 UTC

custom scorer

Hello,
I'm trying to write a custom scorer that only uses the term frequency function from the DefaultSimilarity class, the problem is that documents with lower frequencies are returning with higher scores than documents with higher frequencies.  Here's the code:
searcher.setSimilarity(new DefaultSimilarity(){
 public float lengthNorm(String field, int numTerms){
  return 1;        
 }
 public float idf(int docFreq, int numDocs){
  return 1;
 }
 public float coord(int overlap, int maxoverlap){
  return 1;
 }
 public float queryNorm(float sumOfSquaredWeights){
  return 1;
 }   
 public float sloppyFreq(int distance){
  return 1;
 }
});
Any idea why this wouldn't be working?
Sincerely,
Chris Salem 

Re: custom scorer

Posted by Grant Ingersoll <gs...@apache.org>.
Are you setting the Similarity before indexing, too, on the IndexWriter?

On Aug 19, 2009, at 4:20 PM, Chris Salem wrote:

> Hello,
> I'm trying to write a custom scorer that only uses the term  
> frequency function from the DefaultSimilarity class, the problem is  
> that documents with lower frequencies are returning with higher  
> scores than documents with higher frequencies.  Here's the code:
> searcher.setSimilarity(new DefaultSimilarity(){
> public float lengthNorm(String field, int numTerms){
>  return 1;
> }
> public float idf(int docFreq, int numDocs){
>  return 1;
> }
> public float coord(int overlap, int maxoverlap){
>  return 1;
> }
> public float queryNorm(float sumOfSquaredWeights){
>  return 1;
> }
> public float sloppyFreq(int distance){
>  return 1;
> }
> });
> Any idea why this wouldn't be working?
> Sincerely,
> Chris Salem

--------------------------
Grant Ingersoll
http://www.lucidimagination.com/

Search the Lucene ecosystem (Lucene/Solr/Nutch/Mahout/Tika/Droids)  
using Solr/Lucene:
http://www.lucidimagination.com/search


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