title: ElasticSearch - score boosting using scripting
body: <p>We have a specific use-case for our ElasticSearch instance:  we store documents which contain proper names, dates of birth, addresses, ID numbers, and other related info.</p>
  
  <p>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.</p>
  
  <p>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:</p>
  
  <pre><code>{  
     "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 **&lt;HERE'S WHERE I NEED ASSISTANCE&gt;**"
                               }
                             }
                           }
                         }
                       }
                     }
                   }
                 }
               },
               "query_weight":0.0,
               "rescore_query_weight":1.0
             }
           }
  </code></pre>
  
  <p>The <code>Name</code> field will always be required in a query and is the basis for the score, which is returned in the default <code>_score</code> field; for ease of demonstration, we'll just add one additional field, <code>DOB</code>, which if matched, should boost the score by 0.1.   I believe I'm looking for something along the lines of <code>if(query_value == doc['DOB'].value add 0.1 to _score)</code>, or something along these lines.  </p>
  
  <p>So, what <em>would</em> be the correct syntax to be entered into the <code>inline</code> row to achieve this?  Or, if the query requires other syntax revision, please advise.  </p>
  
  <p>EDIT #1 - it's important to highlight that our <code>DOB</code> field is a <code>text</code> field, not a <code>date</code> field.</p>