Hi,
I finally found the source of the problem I'm having with the custom
similarity.

The setting:
- Solr 5.4.1
- the SpecialSimilarity extends ClassicSimilarity
- for one field this similarity is configured. Everything else uses
ClassicSimilarity because of <similarity
class="solr.SchemaSimilarityFactory"/>

Result:
- most calculation is done by the correct similarity for each field
- but the method public float queryNorm(float valueForNormalization) is
always called on the base class Similarity which always returns 1f

My workaround:
I changed PerFieldSimilarityWrapper and added
@Override
  public float queryNorm(float valueForNormalization) {
    return get("").queryNorm(valueForNormalization);
  }




On Mon, Feb 15, 2016 at 10:28 AM, Markus, Sascha <sas...@uberresearch.com>
wrote:

> Hi,
> I created a custom similarity and factory which extends
> DefaultSimilarity/-Factory to have
>
> to achive this I my similarity overwrites idfExplain like this and also
> the method for an array of terms.
>     public Explanation idfExplain(CollectionStatistics collectionStats,
> TermStatistics termStats) {
>         final long df = lookUpDocumentFrequency(termStats);
>         final long max = getDocumentCountForIDF();
>         final float idf = idf(df, max);
>         log.debug("term:" + termStats.term() + " idf(docFreq=" + df + ",
> maxDocs=" + max + ") -> " + idf);
>         return Explanation.match(idf, "idf(docFreq=" + df + ", maxDocs=" +
> max + ")");
>     }
>
> I configured my similarity for one field in the schema.
>
> Without my plugin the score just uses the fieldWeight.
> But when my similarity is enabled scores are calculated with the
> fieldWeight multiplied by a queryWeight.
> And this is done for ALL FIELDS queried, not only the one with my
> similarity.
>
> Why does this happen and is there a possibility to get around this.
> From a solr point of view this is probably ok because the score is not
> meant to be absolute.
> But in our application a user may set a threshold which is used as a
> filter query like {!frange l=0.31}query($q).
>
> Any hints?
>
> Cheers,
>  Sascha
>
>
>
>

Reply via email to