# Scripting, get value that matched a field

**URL:** <https://discuss.elastic.co/t/scripting-get-value-that-matched-a-field/133503>\
**Category:** Elasticsearch\
**Created:** [May 28, 2018, 9:24am UTC](https://discuss.elastic.co/t/scripting-get-value-that-matched-a-field/133503 "2018-05-28T09:24:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oskars\_Pozdnakovs](https://avatars.discourse-cdn.com/v4/letter/o/c37758/32.png) [@Oskars\_Pozdnakovs](https://discuss.elastic.co/u/Oskars_Pozdnakovs)\
**Post date:** [May 28, 2018, 9:24am UTC](https://discuss.elastic.co/t/scripting-get-value-that-matched-a-field/133503/1 "2018-05-28T09:24:37Z")

</div>

I was wondering if it's possible to obtain the value from a query which matched a particular field to use it in a custom boosting script.

I essentially need to calculate the score of how well a value from multi\_match query matched an edgeNGram field based on the similarity of their length.

E.g.

**"15 Burnaby Road, B7 4LR"** is a better match than  
**"1 Burnaby Road, B7 4LR"** for  
**"155 Burnaby Road, B7 4LR"**

Where house number, street name and postcode are separate fields.

I'm looking to get hold of 1 and 15 values in "function\_score" query to calculate boosting based on how well they match the value 155 in "houseNr" field.

I'm interested only in tools & techniques that are built in Elasticsearch.

---

<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:** [June 25, 2018, 9:24am UTC](https://discuss.elastic.co/t/scripting-get-value-that-matched-a-field/133503/2 "2018-06-25T09:24:41Z")

</div>

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