# Elasticsearch boost query for a certain date value

**URL:** https://discuss.elastic.co/t/elasticsearch-boost-query-for-a-certain-date-value/27610
**Category:** Elasticsearch
**Created:** [August 18, 2015, 6:19pm UTC](https://discuss.elastic.co/t/elasticsearch-boost-query-for-a-certain-date-value/27610 "2015-08-18T18:19:26Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Malini](https://avatars.discourse-cdn.com/v4/letter/m/f05b48/32.png) [@Malini](https://discuss.elastic.co/u/Malini)
#### Post date: [August 18, 2015, 6:19pm UTC](https://discuss.elastic.co/t/elasticsearch-boost-query-for-a-certain-date-value/27610/1 "2015-08-18T18:19:27Z")

</div>

I have the following query. I need to add boost factor when the pubdate is greater than 2013-01.  
How can I achieve that?

curl -XGET '[http://localhost:9200/cs/test/\_search?pretty=true](http://localhost:9200/cs/test/_search?pretty=true)' -d '  
{

"from" : 0,  
"size" : 10,  
"query" : {  
"function\_score" : {  
"query" : {  
"filtered" : {  
"query" : {  
"multi\_match" : {  
"query" : "java",  
"fields" : ["title"]  
}  
},  
"filter" : {  
"and" : {  
"filters" : [ {  
"terms" : {  
"dbname" : ["pubs", "pub2"]  
}  
}, {  
"range" : {  
"pubdate" : {  
"from" : "1980-01",  
"to" : "2015-06",  
"include\_lower" : true,  
"include\_upper" : true  
}  
}  
} ]  
}  
}  
}  
},  
"functions" : [ {  
"filter" : {  
"terms" : {  
"dbname" : ["pub2"]  
}  
},  
"boost\_factor" : -10.0  
} ]  
}  
},  
"sort" : [ {  
"\_score" : {  
"order" : "desc"  
}  
}, {  
"pubdate" : {  
"order" : "desc"  
}  
} ]  
}'

---

<div class="post-metadata">

### Author: ![json](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/json/32/4125_2.png) [@json](https://discuss.elastic.co/u/json)
#### Post date: [August 18, 2015, 10:07pm UTC](https://discuss.elastic.co/t/elasticsearch-boost-query-for-a-certain-date-value/27610/2 "2015-08-18T22:07:05Z")

</div>

Hi Malini,

I'll bite. I tried this out with some Stackoverflow data I have and came up with this:

```auto
POST /stack/_search
{
  "query": {
    "function_score": {
      "query": {"match": {
        "body": "java"
      }},
      "functions": [
        {
          "filter": {
            "range": {
              "creation_date": {
                "gte": "2014-09-09"
              }
            }
          }
          , "weight": 5
        }
      ]
    }
  }
}

```

Here, I tell ES I want to modify the scoring of my query by multiplying the document score by the "weight" value for the documents in the given filter. Please try it out and post back if you get expected results.

--  
Jason

---

<div class="post-metadata">

### Author: ![Malini](https://avatars.discourse-cdn.com/v4/letter/m/f05b48/32.png) [@Malini](https://discuss.elastic.co/u/Malini)
#### Post date: [September 2, 2015, 9:14pm UTC](https://discuss.elastic.co/t/elasticsearch-boost-query-for-a-certain-date-value/27610/3 "2015-09-02T21:14:23Z")

</div>

Thanks for you response.

---

<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:52pm UTC](https://discuss.elastic.co/t/elasticsearch-boost-query-for-a-certain-date-value/27610/4 "2017-07-05T23:52:29Z")

</div>


