# Elasticsearch add numeric field to which represent document relevance?

**URL:** <https://discuss.elastic.co/t/elasticsearch-add-numeric-field-to-which-represent-document-relevance/37101>\
**Category:** Elasticsearch\
**Created:** [December 14, 2015, 8:01am UTC](https://discuss.elastic.co/t/elasticsearch-add-numeric-field-to-which-represent-document-relevance/37101 "2015-12-14T08:01:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jlp1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jlp1/32/6607_2.png) [@jlp1](https://discuss.elastic.co/u/jlp1)\
**Post date:** [December 14, 2015, 8:01am UTC](https://discuss.elastic.co/t/elasticsearch-add-numeric-field-to-which-represent-document-relevance/37101/1 "2015-12-14T08:01:06Z")

</div>

I am using Elasticsearch and NEST to query posts similar to Stackoverflow's.

```
public class Post
{        
   public string Id { get; set; }       
   public string Title { get; set; }
   public string Body { get; set; }   
   public IEnumerable<string> Tags { get; set; }     
   public int Score { get; set; }        
   public int Views{ get; set; }
 }

```

I want Elasticsearch to look at Score and Views when calculating hits relevance, so that high Score or Views value move results higher in the results.

---

<div class="post-metadata">

**Author:** ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)\
**Post date:** [December 14, 2015, 8:21am UTC](https://discuss.elastic.co/t/elasticsearch-add-numeric-field-to-which-represent-document-relevance/37101/2 "2015-12-14T08:21:50Z")

</div>

Hi jlp1

this looks like a good use case for the [Function Score Query](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html), especially the `field_value_factor` option. You probably need to tweak the weights and modifier a bit depending on the numeric ranges your score and views fields take.

---

<div class="post-metadata">

**Author:** ![jlp1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jlp1/32/6607_2.png) [@jlp1](https://discuss.elastic.co/u/jlp1)\
**Post date:** [December 15, 2015, 1:11pm UTC](https://discuss.elastic.co/t/elasticsearch-add-numeric-field-to-which-represent-document-relevance/37101/3 "2015-12-15T13:11:04Z")

</div>

Thanks, I found an example: [https://www.elastic.co/guide/en/elasticsearch/guide/current/boosting-by-popularity.html](https://www.elastic.co/guide/en/elasticsearch/guide/current/boosting-by-popularity.html)

---

<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:30pm UTC](https://discuss.elastic.co/t/elasticsearch-add-numeric-field-to-which-represent-document-relevance/37101/4 "2017-07-05T23:30:56Z")

</div>


