# Custom score with distance levenstein

**URL:** <https://discuss.elastic.co/t/custom-score-with-distance-levenstein/16734>\
**Category:** Elasticsearch\
**Created:** [April 1, 2014, 9:11am UTC](https://discuss.elastic.co/t/custom-score-with-distance-levenstein/16734 "2014-04-01T09:11:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![maryline\_x](https://avatars.discourse-cdn.com/v4/letter/m/f0a364/32.png) [@maryline\_x](https://discuss.elastic.co/u/maryline_x)\
**Post date:** [April 1, 2014, 9:11am UTC](https://discuss.elastic.co/t/custom-score-with-distance-levenstein/16734/1 "2014-04-01T09:11:34Z")

</div>

hi,

In first time I am sorry about my English.

I want scoring my document with only the distance levenstein.  
I try to custom the Similarity but it doesn't work (i don't manage to  
change the value of queryNorm)  
I don't know how i can use the function\_score.  
So i try to extends AbstractFloatSearchScript, to do something like that.  
How can i have the value of the query ?

```
public float runAsFloat() {
    
    LuceneLevenshteinDistance distance = new LuceneLevenshteinDistance

```

();

```
    String nomDoc = docFieldStrings("nom").getValue();
    float score = distance.getDistance(nomDoc, nomQuery);

    return score;
}

And I think there is a better way to do that.
I wait with pleasure for your proposals

```

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/2fcdae1c-79b3-4056-9f6c-aa6bfc30271c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2fcdae1c-79b3-4056-9f6c-aa6bfc30271c%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 2017, 1:39am UTC](https://discuss.elastic.co/t/custom-score-with-distance-levenstein/16734/2 "2017-07-06T01:39:03Z")

</div>


