# Elasticsearch Script\_score

**URL:** <https://discuss.elastic.co/t/elasticsearch-script-score/42197>\
**Category:** Elasticsearch\
**Created:** [February 18, 2016, 9:27pm UTC](https://discuss.elastic.co/t/elasticsearch-script-score/42197 "2016-02-18T21:27:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lifo888](https://avatars.discourse-cdn.com/v4/letter/l/6a8cbe/32.png) [@lifo888](https://discuss.elastic.co/u/lifo888)\
**Post date:** [February 18, 2016, 9:27pm UTC](https://discuss.elastic.co/t/elasticsearch-script-score/42197/1 "2016-02-18T21:27:21Z")

</div>

Hi,

I'm trying to run a match query and get the result sorted based on the term frequency only, but 'im having some difficulty forming the query. I have the following script query but am getting the following exception when i try to run it.

{  
"error" : "SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[jp7D\_tr5TV6bSbiBCTlxsg][my\_index][0]: RemoteTransportException[[Loss][inet[]][indices:data/read/search[phase/query]]]; nested: QueryPhaseExecutionException[[my\_index][0]: query[filtered(function score (headline:long,function=script[\_index[headline][long].tf()], params [null]))-\>cache(\_type:my\_type)],from[0],size[10]: Query Failed [Failed to execute main query]]; nested: GroovyScriptExecutionException[MissingPropertyException[No such property: headline for class: ed6b97f80038ada8c3d6e5ceec691bb004ec6de0]]; }{[SpJJIZdRQ5ePUYkjpeQsGQ][my\_index][1]: QueryPhaseExecutionException[[my\_index][1]: query[filtered(function score (headline:long,function=script[\_index[headline][long].tf()], params [null]))-\>cache(\_type:my\_type)],from[0],size[10]: Query Failed [Failed to execute main query]]; nested: GroovyScriptExecutionException[MissingPropertyException[No such property: headline for class: ed6b97f80038ada8c3d6e5ceec691bb004ec6de0]]; }{[jp7D\_tr5TV6bSbiBCTlxsg][my\_index][2]: RemoteTransportException[[Loss][inet[]][indices:data/read/search[phase/query]]]; nested: QueryPhaseExecutionException[[my\_index][2]: query[filtered(function score (headline:long,function=script[\_index[headline][long].tf()], params [null]))-\>cache(\_type:my\_type)],from[0],size[10]: Query Failed [Failed to execute main query]]; nested: GroovyScriptExecutionException[MissingPropertyException[No such property: headline for class: ed6b97f80038ada8c3d6e5ceec691bb004ec6de0]]; }{[SpJJIZdRQ5ePUYkjpeQsGQ][my\_index][3]: QueryPhaseExecutionException[[my\_index][3]: query[filtered(function score (headline:long,function=script[\_index[headline][long].tf()], params [null]))-\>cache(\_type:my\_type)],from[0],size[10]: Query Failed [Failed to execute main query]]; nested: GroovyScriptExecutionException[MissingPropertyException[No such property: headline for class: ed6b97f80038ada8c3d6e5ceec691bb004ec6de0]]; }{[SpJJIZdRQ5ePUYkjpeQsGQ][my\_index][4]: QueryPhaseExecutionException[[my\_index][4]: query[filtered(function score (headline:long,function=script[\_index[headline][long].tf()], params [null]))-\>cache(\_type:my\_type)],from[0],size[10]: Query Failed [Failed to execute main query]]; nested: GroovyScriptExecutionException[MissingPropertyException[No such property: headline for class: ed6b97f80038ada8c3d6e5ceec691bb004ec6de0]]; }]",  
"status" : 500  
}

```
curl -XGET 'deva01:9800/my_index/my_type/_search?pretty' -d '
{
    "_source": [
        "headline"
    ],
    "query": {
        "filtered": {
            "query": {
                "function_score": {
                    "query": {
                        "match": {
                            "headline": "long"
                        }
                    },
                    "boost_mode": "replace",
                    "functions": [
                        {
                            "script_score": {
                                "script": "_index['headline']['long'].tf()"
                            }
                        }
                    ]
                }
            }
        }
    },
    "size": 10,
    "track_scores": true
}
'

```

Does anyone know what is wrong with my query? Sorry if i missed soemthing obvious, this is my first time running scripting query on ES.

Thanks!

---

<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:15pm UTC](https://discuss.elastic.co/t/elasticsearch-script-score/42197/2 "2017-07-05T23:15:06Z")

</div>


