I have a question about moving a trivial (?) Similarity class from version
4.x to 6.x

I have queries along these lines: field1:somevalue^0.55
field2:anothervalue^1.4
The score for a document is simply the sum of weights. A hit on field1
alone scores 0.55. Field2 alone scores 1.4. Both fields scores 1.95

The codebase I am dealing with is based on 4.x, and has a similarity class
like this:
----------------------------------------------
public class MySimilarity extends Similarity {

   public long computeNorm(FieldInvertState state) {
      return 1;
   }

   public SimWeight computeWeight(float queryBoost, CollectionStatistics
collectionStats, TermStatistics... termStats) {
      return new MySimWeight(queryBoost);
   }

   public SimScorer simScorer(SimWeight weight, AtomicReaderContext
context) throws IOException {
      return new MySimScorer((MySimWeight)weight);
   }

   public static class MySimScorer extends Similarity.SimScorer {
      public MySimWeight weight;

      ...

     public float score(int doc, float freq) {
        return freq > 0.0 ? weight.boost : 0.0f; // don't count >1
occurrence
     }

     public float computeSlopFactor(int distance) {
        return 1.0f / (distance + 1);
     }

     public float computePayloadFactor(int doc, int start, int end,
BytesRef payload) {
        return 1.0f;
     }

  }

    public static class MySimWeight extends SimWeight {
      public float topLevelBoost;
      public float queryBoost;
      public float boost;

     public MySimWeight(float queryBoost) {
        this.queryBoost = queryBoost;
     }

     public float getValueForNormalization() {
        return 1.0f;
     }


     public void normalize(float queryNorm, float topLevelBoost) {
        this.topLevelBoost = topLevelBoost;
        this.boost = this.queryBoost * topLevelBoost;
     }
   }
}
----------------------------------------------

How would I adapt this for Solr 6.x where the boosting factor no longer
appears in the Similarity methods?

Reply via email to