title: Boost score based on integer value - Elasticsearch
body: <p>I'm not very experienced with ElasticSearch and would like to know how to boost a search based on a certain integer value.</p>
  
  <p>This is an example of a document:</p>
  
  <pre><code>{
      "_index": "links",
      "_type": "db1",
      "_id": "mV32vWcBZsblNn1WqTcN",
      "_score": 8.115617,
      "_source": {
          "url": "example.com",
          "title": "Example website",
          "description": "This is an example website, used for various of examples around the world",
          "likes": 9,
          "popularity": 543,
          "tags": [
              {
                  "name": "example",
                  "votes": 5
              },
              {
                  "name": "test",
                  "votes": 2
              },
              {
                  "name": "testing",
                  "votes": 1
              }
          ]
      }
  }
  </code></pre>
  
  <p>Now in this particular search, the focus is on the <code>tags</code> and I would like to know how to boost the <code>_score</code> and multiply it by the integer in the <code>votes</code> under <code>tags</code>.</p>
  
  <p>If this is not possible (or very hard to achieve), I would simply like to know how to boost the <code>_score</code> by the <code>votes</code> (not under <code>tags</code>)</p>
  
  <p>Example, add 0.1 to the <code>_score</code> for each integer in <code>votes</code></p>
  
  <p>This is the current search query I'm using (for searching tags <strong>only</strong>):</p>
  
  <pre><code>{
      "query": {
          "nested": {
              "path": "tags",
              "query": {
                  "bool":{
                      "should":{
                          "match":{
                              "tags.name":"example,testing,something else"
                          }
                      }
                  }
              }
          }
      }
  }
  </code></pre>
  
  <hr>
  
  <p>I couldn't find much online, and hope someone can help me out.</p>
  
  <p>How do I boost the <code>_score</code> with an integer value?</p>
  
  <hr>
  
  <h2>Update</h2>
  
  <p>For more info, here is the mapping:</p>
  
  <pre><code>{
      "links": {
          "mappings": {
              "db1": {
                  "properties": {
                      "url": {
                          "type": "text",
                          "fields": {
                              "keyword": {
                                  "type": "keyword",
                                  "ignore_above": 256
                              }
                          }
                      },
                      "title": {
                          "type": "text",
                          "fields": {
                              "keyword": {
                                  "type": "keyword",
                                  "ignore_above": 256
                              }
                          }
                      },
                      "description": {
                          "type": "text",
                          "fields": {
                              "keyword": {
                                  "type": "keyword",
                                  "ignore_above": 256
                              }
                          }
                      },
                      "likes": {
                          "type": "long"
                      },
                      "popularity": {
                          "type": "long"
                      },
                      "tags": {
                          "type": "nested",
                          "properties": {
                              "name": {
                                  "type": "text",
                                  "fields": {
                                      "keyword": {
                                          "type": "keyword",
                                          "ignore_above": 256
                                      }
                                  }
                              },
                              "votes": {
                                  "type": "long"
                              }
                          }
                      }
                  }
              }
          }
      }
  }
  </code></pre>
  
  <h2>Update 2</h2>
  
  <p>Changed the <code>tags.likes</code>/<code>tags.dislikes</code> to <code>tags.votes</code>, and added a <code>nested</code> property to the <code>tags</code></p>