# Custom similarity scoring

**URL:** <https://discuss.elastic.co/t/custom-similarity-scoring/135168>\
**Category:** Elasticsearch\
**Created:** [June 8, 2018, 2:18pm UTC](https://discuss.elastic.co/t/custom-similarity-scoring/135168 "2018-06-08T14:18:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![matanster](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matanster/32/32063_2.png) [@matanster](https://discuss.elastic.co/u/matanster)\
**Post date:** [June 8, 2018, 2:18pm UTC](https://discuss.elastic.co/t/custom-similarity-scoring/135168/1 "2018-06-08T14:18:34Z")

</div>

Hi,

I'm interested in implementing a custom version of Levenshtein Distance that accumulates edit distance in a finer-grained way than the base algorithm, namely basing the distance on specific characters being deleted/inserted and such, using a continuous value rather than accumulating distance in quanta of size one. In fact I have this code working outside of elasticsearch and the base algorithm is anyway amenable to such refinements.

By the way, this question is a continuation in part to [this one](https://discuss.elastic.co/t/custom-score-for-fuzzy-matching-based-on-levenshtein-distance-score/125544/4?u=matanster), regarding coding your own similarity measures.

So Firstly, I would like to refine about why a Java plugin would be the preferred way of implementation/integration, as opposed to the [script\_score](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html#function-script-score) function which has also mentioned in the same context. Why is one recommended over the other? are there other, additional options? under what terms would a pull request for a new (and parameterizable) distance calculation option be likely to be accepted?

If indeed a Java plugin is the way to go, I would like to learn whether a Java plugin will hook into [here in the source](https://github.com/elastic/elasticsearch/blob/99f88f15c5febbca2d13b5b5fda27b844153bf1a/server/src/main/java/org/elasticsearch/search/suggest/term/TermSuggestionBuilder.java#L531) or would it be called somewhere very differently in the source? a way to hook in as a new similarity scorer, does not easily arise in the single [Java plugin example included in the source](https://github.com/elastic/elasticsearch/tree/6.2/plugins/jvm-example/src/main/java/org/elasticsearch/plugin/example).

Last but certainly not least (!) it's been implied in the older post I refer to, that writing a Java plugin is under-documented or outdated, so I wonder whether you could kindly point me at a good and current piece of documentation for it....

I Would be very thankful for getting some enablement for approaching this very efficiently

Thanks in advance!

Matan

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2018, 2:18pm UTC](https://discuss.elastic.co/t/custom-similarity-scoring/135168/2 "2018-07-06T14:18:44Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
