# Accessing matched term in script score function

**URL:** <https://discuss.elastic.co/t/accessing-matched-term-in-script-score-function/44837>\
**Category:** Elasticsearch\
**Created:** [March 18, 2016, 12:05pm UTC](https://discuss.elastic.co/t/accessing-matched-term-in-script-score-function/44837 "2016-03-18T12:05:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Red](https://avatars.discourse-cdn.com/v4/letter/r/59ef9b/32.png) [@Red](https://discuss.elastic.co/u/Red)\
**Post date:** [March 18, 2016, 12:05pm UTC](https://discuss.elastic.co/t/accessing-matched-term-in-script-score-function/44837/1 "2016-03-18T12:05:35Z")

</div>

i have some problem with script score.  
i want to caculate the score with matched term.  
in most situation, i just need the count of matched term.  
but i want to know what term are the matched terms, and i can do some adjusting to different terms.

for query string "test A B C"  
terms analyzed by index's analyzer will be: "test" "A" "B" "C"

if i just know the count of matched terms to one document, the score will be 4, 3, 2, 1 or 0.  
but i want to have some extra points to term "A",  
the point will be like this: A\*10 + B \* 1 + C \* 1

someone has asked for the same problem before, but his has a little different from mine.

> <https://github.com/elastic/elasticsearch/issues/13806>

i need the query string analyzed by indexer's analyzer. the query string are always given by user input, i thinks its better be analyzed by es, i just have to make some policy to the terms analyzed by es.

---

<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 5, 2017, 11:07pm UTC](https://discuss.elastic.co/t/accessing-matched-term-in-script-score-function/44837/2 "2017-07-05T23:07:12Z")

</div>


