# script\_score return is strange

**URL:** https://discuss.elastic.co/t/script-score-return-is-strange/29207
**Category:** Elasticsearch
**Created:** [September 13, 2015, 10:49pm UTC](https://discuss.elastic.co/t/script-score-return-is-strange/29207 "2015-09-13T22:49:55Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![jianfeng\_ye](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jianfeng_ye/32/4753_2.png) [@jianfeng\_ye](https://discuss.elastic.co/u/jianfeng_ye)
#### Post date: [September 13, 2015, 10:49pm UTC](https://discuss.elastic.co/t/script-score-return-is-strange/29207/1 "2015-09-13T22:49:55Z")

</div>

I need to get documents order by custom score, so i use script\_score:

```
$params = [
            'index' => "questions",
            'type' => "baichebao",
            'body' => [
                'from' => $from,
                'size' => $size,
                'sort' => [
                    "_score" => 'asc',
                ],
                'query' => [
                    'bool' => [
                        'should' => [
                            'function_score' => [
                                'query' => [
                                    'match' => [
                                        'content' => '斯巴鲁',
                                    ]
                                ],
                                'script_score' => [
                                    "lang" => "groovy",
                                    'params' => [
                                        'now' => 1442184014,
                                    ],
                                    'script' => 'now - doc["created_at"].value',
                                ],
                            ]
                        ]
                    ]
                ]
            ]
        ];

```

and I got the documents like

```
{
    "code": 0,
    "message": "处理成功",
    "timestamp": 1442184477,
    "im": true,
    "result": {
        "took": 6,
        "timed_out": false,
        "_shards": {
            "total": 5,
            "successful": 5,
            "failed": 0
        },
        "hits": {
            "total": 2680,
            "max_score": null,
            "hits": [
                {
                    "_index": "questions",
                    "_type": "baichebao",
                    "_id": "2536263",
                    "_score": 740085.6,
                    "_source": {
                        "id": 2536263,
                        "content": "06年斯巴鲁力狮4at，近日出现行驶中熄火，油温过高指示灯闪一下就熄火，感觉车身下面确实有一点热，而且熄火前发动机转数还会乱跳，开着有点供不上油的感觉，时好时坏",
                        "uid": 877461,
                        "all_answer_count": 33,
                        "answer_users": 1,
                        "best_answer": 2951111,
                        "status": 1,
                        "is_closed": false,
                        "tags": [
                            "故障维修"
                        ],
                        "channel_type": 3,
                        "channel_sub_type": 0,
                        "created_at": 1441386486,
                        "distrust": 0,
                        "is_expert": false,
                        "series_id": 0
                    },
                    "sort": [
                        740085.6
                    ]
                }
            ]
        }
    }
}

```

please notice the \_score is 740085.6, but my script will be : 1442184014-1441386486, how the elasticsearch got the strange score?

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [September 14, 2015, 2:14am UTC](https://discuss.elastic.co/t/script-score-return-is-strange/29207/2 "2015-09-14T02:14:27Z")

</div>

Please see [My query result will change in same params](https://discuss.elastic.co/t/my-query-result-will-change-in-same-params/29208)

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [September 14, 2015, 2:14am UTC](https://discuss.elastic.co/t/script-score-return-is-strange/29207/3 "2015-09-14T02:14:30Z")

</div>


