Custom Similarity in plugin

Hi, I tried to use a custom similarity in a plugin to score with payload. To do so I extended ClassicSimilarity and redefined scorePayload.

Once the plugin is deployed, the score does not change with payload. Actually it seems that score payload is never called.

Any idea ?

public class PayloadSimilarity extends ClassicSimilarity {
    
  @Override
  public float tf(float freq) {
    return 1.0F;
  }
  
  
   @Override
   public float scorePayload(int doc, int start, int end, BytesRef payload) {
     if (payload != null) {
       return PayloadHelper.decodeFloat(payload.bytes, payload.offset);
     } else {
       return 1.0F;
    }
   }

  @Override
   public String toString() {
     return "PayloadSimilarity";
  }    
}

I defined the provided :

 public class PayloadSimilarityProvider extends AbstractSimilarityProvider {

  private final PayloadSimilarity similarity = new PayloadSimilarity();

   @Inject
  public PayloadSimilarityProvider(@Assisted String name, @Assisted Settings settings) {
    super(name);
  }

  @Override
  public Similarity get() {
    return similarity;
  }

}

And declared my similarity like so in the plugin :

public void onModule(SimilarityModule module) {
  module.addSimilarity("payload", PayloadSimilarityProvider.class);
}

Any clue would be welcome.

I have an example of term position scoring.
https://github.com/sdauletau/elasticsearch-position-similarity.