title: elasticsearch ngrams results are wrong
body: <p>I am trying to implement partial matching using ngrams in elasticsearch but not getting the expected results out of it.<br>
  I am following this link:-</p>
  
  <p><a href="https://www.elastic.co/guide/en/elasticsearch/guide/current/_index_time_search_as_you_type.html" rel="nofollow">https://www.elastic.co/guide/en/elasticsearch/guide/current/_index_time_search_as_you_type.html</a> 
  <br>
  I have done all the things which are mentioned in this link. My dataset contains 3 fields i.e id,name,age.</p>
  
  <p>Here is my mapping and setting of my_index<br></p>
  
  <pre><code>GET /my_index/_settings
  {
     "my_index": {
        "settings": {
           "index": {
              "creation_date": "1433249154544",
              "uuid": "hKxHVnqaRVmji31xK92pVA",
              "number_of_replicas": "1",
              "analysis": {
                 "filter": {
                    "autocomplete_filter": {
                       "type": "edge_ngram",
                       "min_gram": "1",
                       "max_gram": "20"
                    }
                 },
                 "analyzer": {
                    "autocomplete": {
                       "type": "custom",
                       "filter": [
                          "lowercase",
                          "autocomplete_filter"
                       ],
                       "tokenizer": "standard"
                    }
                 }
              },
              "number_of_shards": "1",
              "version": {
                 "created": "1040499"
              }
           }
        }
     }
  }
  </code></pre>
  
  <p><br></p>
  
  <pre><code>GET /my_index/_mapping/my_type
  {
     "my_index": {
        "mappings": {
           "my_type": {
              "properties": {
                 "@timestamp": {
                    "type": "date",
                    "format": "dateOptionalTime"
                 },
                 "@version": {
                    "type": "string"
                 },
                 "age": {
                    "type": "long"
                 },
                 "host": {
                    "type": "string"
                 },
                 "id": {
                    "type": "string"
                 },
                 "message": {
                    "type": "string"
                 },
                 "name": {
                    "type": "string",
                    "index_analyzer": "autocomplete",
                    "search_analyzer": "standard"
                 },
                 "path": {
                    "type": "string"
                 },
                 "type": {
                    "type": "string"
                 }
              }
           }
        }
     }
  }
  </code></pre>
  
  <p><br> My query to elastic search is :-<br></p>
  
  <pre><code>GET /my_index/my_type/_search
  {
      "query": {
          "match": {
              "name": {
                  "query":    "raman r"
              }
          }
      }
  }
  </code></pre>
  
  <p><br> According to me now the results should display only "raman ram" but it is also showing other results as well:-</p>
  
  <pre><code>{
     "took": 13,
     "timed_out": false,
     "_shards": {
        "total": 1,
        "successful": 1,
        "failed": 0
     },
     "hits": {
        "total": 9,
        "max_score": 2.6631343,
        "hits": [
           {
              "_index": "my_index",
              "_type": "my_type",
              "_id": "2",
              "_score": 2.6631343,
              "_source": {
                 "message": [
                    "2,raman,23"
                 ],
                 "@version": "1",
                 "@timestamp": "2015-06-02T13:07:18.041Z",
                 "type": "my_type",
                 "host": "shubham-VirtualBox",
                 "path": "/home/shubham/sample.csv",
                 "id": "2",
                 "name": "raman",
                 "age": 23
              }
           },
           {
              "_index": "my_index",
              "_type": "my_type",
              "_id": "10",
              "_score": 1.8003473,
              "_source": {
                 "message": [
                    "10,raman ram,43"
                 ],
                 "@version": "1",
                 "@timestamp": "2015-06-02T13:11:03.455Z",
                 "type": "my_type",
                 "host": "shubham-VirtualBox",
                 "path": "/home/shubham/sample.csv",
                 "id": "10",
                 "name": "raman ram",
                 "age": 43
              }
           },
           {
              "_index": "my_index",
              "_type": "my_type",
              "_id": "1",
              "_score": 0.26245093,
              "_source": {
                 "message": [
                    "1,Ram,342"
                 ],
                 "@version": "1",
                 "@timestamp": "2015-06-02T13:07:18.040Z",
                 "type": "my_type",
                 "host": "shubham-VirtualBox",
                 "path": "/home/shubham/sample.csv",
                 "id": "1",
                 "name": "Ram",
                 "age": 342
              }
           },
           {
              "_index": "my_index",
              "_type": "my_type",
              "_id": "3",
              "_score": 0.26245093,
              "_source": {
                 "message": [
                    "3,ramayan,23"
                 ],
                 "@version": "1",
                 "@timestamp": "2015-06-02T13:07:18.041Z",
                 "type": "my_type",
                 "host": "shubham-VirtualBox",
                 "path": "/home/shubham/sample.csv",
                 "id": "3",
                 "name": "ramayan",
                 "age": 23
              }
           },
           {
              "_index": "my_index",
              "_type": "my_type",
              "_id": "4",
              "_score": 0.26245093,
              "_source": {
                 "message": [
                    "4,ramaram,231"
                 ],
                 "@version": "1",
                 "@timestamp": "2015-06-02T13:07:18.041Z",
                 "type": "my_type",
                 "host": "shubham-VirtualBox",
                 "path": "/home/shubham/sample.csv",
                 "id": "4",
                 "name": "ramaram",
                 "age": 231
              }
           },
           {
              "_index": "my_index",
              "_type": "my_type",
              "_id": "5",
              "_score": 0.26245093,
              "_source": {
                 "message": [
                    "5,rampy,1"
                 ],
                 "@version": "1",
                 "@timestamp": "2015-06-02T13:07:18.041Z",
                 "type": "my_type",
                 "host": "shubham-VirtualBox",
                 "path": "/home/shubham/sample.csv",
                 "id": "5",
                 "name": "rampy",
                 "age": 1
              }
           },
           {
              "_index": "my_index",
              "_type": "my_type",
              "_id": "6",
              "_score": 0.26245093,
              "_source": {
                 "message": [
                    "6,ration,11"
                 ],
                 "@version": "1",
                 "@timestamp": "2015-06-02T13:07:18.041Z",
                 "type": "my_type",
                 "host": "shubham-VirtualBox",
                 "path": "/home/shubham/sample.csv",
                 "id": "6",
                 "name": "ration",
                 "age": 11
              }
           },
           {
              "_index": "my_index",
              "_type": "my_type",
              "_id": "7",
              "_score": 0.26245093,
              "_source": {
                 "message": [
                    "7,rita,42"
                 ],
                 "@version": "1",
                 "@timestamp": "2015-06-02T13:07:18.042Z",
                 "type": "my_type",
                 "host": "shubham-VirtualBox",
                 "path": "/home/shubham/sample.csv",
                 "id": "7",
                 "name": "rita",
                 "age": 42
              }
           },
           {
              "_index": "my_index",
              "_type": "my_type",
              "_id": "8",
              "_score": 0.26245093,
              "_source": {
                 "message": [
                    "8,roni,45"
                 ],
                 "@version": "1",
                 "@timestamp": "2015-06-02T13:07:18.050Z",
                 "type": "my_type",
                 "host": "shubham-VirtualBox",
                 "path": "/home/shubham/sample.csv",
                 "id": "8",
                 "name": "roni",
                 "age": 45
              }
           }
        ]
     }
  }
  </code></pre>