# Score-Boosting Using Scripting

**URL:** <https://discuss.elastic.co/t/score-boosting-using-scripting/189796>\
**Category:** Elasticsearch\
**Created:** [July 10, 2019, 2:33pm UTC](https://discuss.elastic.co/t/score-boosting-using-scripting/189796 "2019-07-10T14:33:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nola111](https://avatars.discourse-cdn.com/v4/letter/n/5e9695/32.png) [@nola111](https://discuss.elastic.co/u/nola111)\
**Post date:** [July 10, 2019, 2:33pm UTC](https://discuss.elastic.co/t/score-boosting-using-scripting/189796/1 "2019-07-10T14:33:24Z")

</div>

We have documents in ElasticSearch which contain proper names, dates of birth, addresses, ID numbers, and other related info.

We use a name-matching plugin which overrides the default scoring of ES and assigns a relevancy score between 0 and 1 based on how closely the name matches.

What we need to do is boost that score by a certain amount if other fields match. I have started to read up on ES scripting to achieve this. I need assistance on the script part of the query. Right now, our query looks like this:

```
{  
   "size":100,
   "query":{  
      "bool":{  
         "should":[  
            {"match":{"Name":"John Smith"}}
            ]
         }
   },
   "rescore":{  
         "window_size":100,
         "query":{  
            "rescore_query":{  
               "function_score":{  
                  "doc_score":{  
                     "fields":{
                       "Name":{"query_value":"John Smith"},
                       "DOB":{
                     	"function":{
                     		"function_score":{
                     			"script_score":{
                     				"script":{
                     					"lang":"painless",
                     					"params":{
                     						"query_value":"01-01-1999"
                     					         },
                     		   "inline":"if **<HERE'S WHERE I NEED ASSISTANCE>**"
                     		 }
                     	   }
                     	 }
                       }
                     }
                   }
                 }
               }
             },
             "query_weight":0.0,
             "rescore_query_weight":1.0
           }
         }

```

The `Name` field will always be required in a query and is the basis for the score, which is returned in the default `_score` field; for ease of demonstration, we'll just add one additional field, `DOB`, which if matched, should boost the score by 0.1. I believe I'm looking for something along the lines of `if(query_value == doc['DOB'].value add 0.1 to _score)`, or something along these lines.

So, what _would_ be the correct syntax to be entered into the `inline` row to achieve this? Or, if the query requires other syntax revision, please advise.

---

<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:** [August 7, 2019, 2:33pm UTC](https://discuss.elastic.co/t/score-boosting-using-scripting/189796/2 "2019-08-07T14:33:25Z")

</div>

Closed on August 7, 2019, 2:33pm UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
