Hello I made a very simple custom similarity, mainly for testing and
learning:

public class StaticNormSimilarity extends DefaultSimilarity {

  private static final Logger LOG =
LoggerFactory.getLogger(StaticNormSimilarity.class);
  private float norm = 0.1f;

  public void setNorm(float norm) {
    this.norm = norm;

    //TODO: not working how can I access parameters
    LOG.info("##gyk: StaticNormSimilarity norm = {}", norm);
    System.out.println(String.format("##gyk: StaticNormSimilarity: %f",norm));
  }
  public float getNorm() {
    return this.norm;
  }

  @Override
  public float queryNorm(float sumOfSquaredWeights) {
    return this.norm;
  }
}

In the schema.xml I set the following:


<fieldType name="text_en" class="solr.TextField" positionIncrementGap="100">
  <similarity class="gyk.solr.similarity.StaticNormSimilarity">
    **HOW CAN I SEE THIS VALUE FROM MY CODE**
    <float name="norm">0.1</float>
  </similarity>
  <analyzer type="index">
  ...
  </analyzer>
  <analyzer type="query">
  ...
  </analyzer></fieldType>*
*
...

<similarity class="solr.SchemaSimilarityFactory" />

My question is how can I see/use from code the *norm* value specified
in the schema.xml file? Thanks in advance.

Reply via email to