# How to access input field value in script in elasticsearch

**URL:** <https://discuss.elastic.co/t/how-to-access-input-field-value-in-script-in-elasticsearch/187547>\
**Category:** Elasticsearch\
**Created:** [June 26, 2019, 10:43am UTC](https://discuss.elastic.co/t/how-to-access-input-field-value-in-script-in-elasticsearch/187547 "2019-06-26T10:43:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![spsanthoshi](https://avatars.discourse-cdn.com/v4/letter/s/90ced4/32.png) [@spsanthoshi](https://discuss.elastic.co/u/spsanthoshi)\
**Post date:** [June 26, 2019, 10:43am UTC](https://discuss.elastic.co/t/how-to-access-input-field-value-in-script-in-elasticsearch/187547/1 "2019-06-26T10:43:40Z")

</div>

I'm using bool query and I want to use matched result value in a script in elastic search

```auto
  {
"query": {
"nested": {
  "path": "Names",
  "query": {
    "function_score": {
      "script_score": {
        "script": {
          "source": "((_score)/(X+doc['Names.count'].value))*100"
        }
      },
      "min_score": 80,
      "query": {
        "bool": {
          "should": [
            {
              "match": {
                "Names.name": "siriporn kanchana"
              }
            },
            {
              "match": {
                "Names.name": "ganjana siriporn"
              }
            }
          ]
        }
      }
    }
  }
}
} }
in above I want X value should be the length of matched string example if sirporn is matched then I want x= 7.is it possible 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:** [July 24, 2019, 10:43am UTC](https://discuss.elastic.co/t/how-to-access-input-field-value-in-script-in-elasticsearch/187547/2 "2019-07-24T10:43:48Z")

</div>

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