Elasticsearch : _score always 0 for tf()
<p>I have this kind of groovy script:</p>

<pre><code>_index[field][term].tf()
</code></pre>

<p>I am indexing this groovy script </p>

<pre><code>POST /_scripts/groovy/getTF
{
     "script": "_index[field][term].tf()"
}
</code></pre>

<p>Then running the following query always returns _score to be zero (sense command)</p>

<pre><code>POST /my_index/document/_search
{
  "query": {
    "function_score": {
      "query": {
        "match": {
          "text": "algorithms"
        }
      },
      "functions": [
        {
          "script_score": {
            "script_id": "getTF",
            "lang" : "groovy",
            "params": {
              "term": "algorithms",
              "field": "text"
            }
          }
        }
      ],
      "boost_mode": "replace"
    }
  },
  "size": 10,
  "fields": ["text"]
}
</code></pre>

<p>What am I doing wrong here? </p>

<p>This is the mapping for the fields</p>

<pre><code>PUT /ap_dataset/document/_mapping
{
  "document": {
    "properties": {
      "docno": {
        "type": "string",
        "store": true,
        "index": "not_analyzed"
      },
      "text": {
        "type": "string",
        "store": true,
        "index": "analyzed",
        "term_vector": "with_positions_offsets_payloads",
        "analyzer": "my_english"
      }
    }
  }
}
</code></pre>