Hi all,

Based on advice I received on a previous email thread, I applied patch
https://issues.apache.org/jira/browse/SOLR-2338. My goal was to be able to
apply a similarity class to certain fields but not all fields.

I ran the following commands:

$ cd <your Solr trunk checkout dir>
$ svn up
$ wget https://issues.apache.org/jira/secure/attachment/12475027/SOLR-2338.patch
$ patch -p0 -i SOLR-2338.patch

And I did not get any errors. I then created my own SimilarityClass
listed below because it isn't very large:

package org.apache.lucene.misc;
import org.apache.lucene.search.DefaultSimilarity;

public class SimpleSimilarity extends DefaultSimilarity {
  public SimpleSimilarity() { super(); }
  public float idf(int dont, int care) { return 1; }
}

As you can see, it isn't very complicated. I'm just trying to remove
the idf from the scoring equation in certain cases.

Next, I make a change to the schema.xml file:

<fieldType name="string_noidf" class="solr.StrField"
sortMissingLast="true" omitNorms="true">
  <similarity class="org.apache.lucene.misc.SimpleSimilarity"/>
</fieldType>

And apply that to the field in question:

<field name="string_noidf" multiValued="true" type="string_noidf"
indexed="true" stored="true" required="false" omitNorms="true" />

But I think something did not get applied correctly to the patch. I
restarted and did a full import but the scores are exactly the same.
Also, I tried using the existing SweetSpotSimilarity:
<fieldType name="string_noidf" class="solr.StrField"
sortMissingLast="true" omitNorms="true">
  <similarity class="org.apache.lucene.misc.SweetSpotSimilarity"/>
</fieldType>

But the scores remained unchanged even in that case. At this point,
I'm not quite sure how to debug this to see whether the problem is
with the patch or the similarity class but given that the SweetSpot
similarity class didn't work either, I'm inclined to think it was a
problem with the patch.

Any thoughts on this one?

Thanks,

Brian Lamb

Reply via email to