title: Elasticsearch Edge NGram tokenizer higher score when word begins with n-gram
body: <p>Suppose there is the following mapping with Edge NGram Tokenizer:</p>
  
  <pre><code>{
    "settings": {
      "analysis": {
        "analyzer": {
          "autocomplete_analyzer": {
            "tokenizer": "autocomplete_tokenizer",
            "filter": [
              "standard"
            ]
          },
          "autocomplete_search": {
            "tokenizer": "whitespace"
          }
        },
        "tokenizer": {
          "autocomplete_tokenizer": {
            "type": "edge_ngram",
            "min_gram": 1,
            "max_gram": 10,
            "token_chars": [
              "letter",
              "symbol"
            ]
          }
        }
      }
    },
    "mappings": {
      "tag": {
        "properties": {
          "id": {
            "type": "long"
          },
          "name": {
            "type": "text",
            "analyzer": "autocomplete_analyzer",
            "search_analyzer": "autocomplete_search"
          }
        }
      }
    }
  }
  </code></pre>
  
  <p>And the following documents are indexed:</p>
  
  <pre><code>POST /tag/tag/_bulk
  {"index":{}}
  {"name" : "HITS FIND SOME"}
  {"index":{}}
  {"name" : "TRENDING HI"}
  {"index":{}}
  {"name" : "HITS OTHER"}
  </code></pre>
  
  <p>Then searching </p>
  
  <pre><code>{
    "query": {
      "match": {
        "name": {
          "query": "HI"
        }
      }
    }
  }
  </code></pre>
  
  <p>yields all with the same score, or <code>TRENDING - HI</code> with a score higher than one of the others. </p>
  
  <p>How can it be configured, to show with a higher score the entries that actually start with the searcher n-gram? In this case, <code>HITS FIND SOME</code> and <code>HITS OTHER</code> to have a higher score than <code>TRENDING HI</code>; at the same time <code>TRENDING HI</code> should be in the results.</p>
  
  <p>Highlighter is also used, so the given solution shouldn't mess it up.</p>
  
  <p>The highlighter used in query is:</p>
  
  <pre><code> "highlight": {
      "pre_tags": [
        "&lt;"
      ],
      "post_tags": [
        "&gt;"
      ],
      "fields": {
        "name": {}
      }
    }
  </code></pre>
  
  <p>Using this with <code>match_phrase_prefix</code> messes up the highlighting, yielding <code>&lt;H&gt;&lt;I&gt;&lt;T&gt;&lt;S&gt; FIND SOME</code> when searching only for <code>H</code>.</p>