# Functions score query returns same score

**URL:** <https://discuss.elastic.co/t/functions-score-query-returns-same-score/46193>\
**Category:** Elasticsearch\
**Created:** [April 4, 2016, 3:24am UTC](https://discuss.elastic.co/t/functions-score-query-returns-same-score/46193 "2016-04-04T03:24:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kannan\_rbk](https://avatars.discourse-cdn.com/v4/letter/k/c57346/32.png) [@kannan\_rbk](https://discuss.elastic.co/u/kannan_rbk)\
**Post date:** [April 4, 2016, 3:24am UTC](https://discuss.elastic.co/t/functions-score-query-returns-same-score/46193/1 "2016-04-04T03:24:05Z")

</div>

I am using functions score with sampler aggregation to match last visited documents.

ES Query

```
{
  "query": {
"function_score": {
  "boost_mode": "replace", // we need to replace document score with the result of the functions,
  "query": {
  },
  "functions": [
    {
      "field_value_factor": { // return `lastvisited` value as score
        "field": "visited_time"
      }
      ,"weight":1
    }
  ]
}
  },
  "size": 10000
}

```

Response

```
{
  "took" : 5,
  "timed_out" : false,
  "_shards" : {
"total" : 2,
"successful" : 2,
"failed" : 0
  },
  "hits" : {
"total" : 5,
"max_score" : 1.45973969E12,
"hits" : [ {
  "_index" : "idx0",
  "_type" : "8001",
  "_id" : "null-100-1459739724631",
  "_score" : 1.45973969E12,
  "_routing" : "100",
  "_source" : {
    "visited_time" : 1459739724636
  }
}, {
  "_index" : "idx0",
  "_type" : "8001",
  "_id" : "null-101-1459708570522",
  "_score" : 1.45970862E12,
  "_routing" : "101",
  "_source" : {
    "visited_time" : 1459708570525
  }
}, {
  "_index" : "idx0",
  "_type" : "8001",
  "_id" : "null-101-1459708599619",
  "_score" : 1.45970862E12,
  "_routing" : "101",
  "_source" : {
    "visited_time" : 1459708599620
  }
}, {
  "_index" : "idx0",
  "_type" : "8001",
  "_id" : "null-100-1459708476386",
  "_score" : 1.45970849E12,
  "_routing" : "100",
  "_source" : {
    "visited_time" : 1459708476387
  }
}, {
  "_index" : "idx0",
  "_type" : "8001",
  "_id" : "null-100-1459708421417",
  "_score" : 1.45970836E12,
  "_routing" : "100",
  "_source" : {
    "visited_time" : 1459708421492
  }
} ]
  }
}

```

I don't know why it returns same document score?

---

<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:02pm UTC](https://discuss.elastic.co/t/functions-score-query-returns-same-score/46193/2 "2017-07-05T23:02:48Z")

</div>


