title: Elastic search cross fields, edge ngram analyzer
body: <p>I have 999 documents which I am using for experimenting with elastic search.</p>
  
  <p>There is a field f4 in my type mapping which is analyzed and has following settings for analyzer :</p>
  
  <pre><code>  "myNGramAnalyzer" =&gt; [
         "type" =&gt; "custom",
          "char_filter" =&gt; ["html_strip"],
          "tokenizer" =&gt; "standard",
          "filter" =&gt; ["lowercase","standard","asciifolding","stop","snowball","ngram_filter"]
    ]
  </code></pre>
  
  <p>My filter is as below :  </p>
  
  <pre><code>  "filter" =&gt; [
          "ngram_filter" =&gt; [
              "type" =&gt; "edgeNGram",
              "min_gram" =&gt; "2",
              "max_gram" =&gt; "20"
          ]
    ]
  </code></pre>
  
  <p>I have value for field f4 as "Proj1", "Proj2", "Proj3"...... so on.</p>
  
  <p>Now when I try to do search using cross fields for "proj1" string, I was expecting document with "Proj1" to be returned at the top of the response with max score. But it doesn't. Rest all the data is almost same in content.</p>
  
  <p><strong>Also I don't understand why it matches all 999 document?</strong></p>
  
  <p>Following is my search :</p>
  
  <pre><code>{
      "index": "myindex",
      "type": "mytype",
      "body": {
          "query": {
              "multi_match": {
                  "query": "proj1",
                  "type": "cross_fields",
                  "operator": "and",
                  "fields": "f*"
              }
          },
          "filter": {
              "term": {
                  "deleted": "0"
              }
          }
      }
  }
  </code></pre>
  
  <p>My search response is :</p>
  
  <pre><code>{
      "took": 12,
      "timed_out": false,
      "_shards": {
          "total": 5,
          "successful": 5,
          "failed": 0
      },
      "hits": {
          "total": 999,
          "max_score": 1,
          "hits": [{
              "_index": "myindex",
              "_type": "mytype",
              "_id": "42",
              "_score": 1,
              "_source": {
                  "f1": "396","f2": "125650","f3": "BH.1511AI.001",
                  "f4": "Proj42",
                  "f5": "BH.1511AI.001","f6": "","f7": "","f8": "","f9": "","f10": "","f11": "","f12": "","f13": "","f14": "","f15": "","f16": "09/05/16 | 01:02PM | User","deleted": "0"
              }
          }, {
              "_index": "myindex",
              "_type": "mytype",
              "_id": "47",
              "_score": 1,
              "_source": {
                  "f1": "396","f2": "137946","f3": "BH.152096.001",
                  "f4": "Proj47",
                  "f5": "BH.1511AI.001","f6": "","f7": "","f8": "","f9": "","f10": "","f11": "","f12": "","f13": "","f14": "","f15": "","f16": "09/05/16 | 01:02PM | User","deleted": "0"
              }
          }, 
          //.......
          //.......
          //MANY RECORDS IN BETWEEN HERE
          //.......
          //.......
          {
              "_index": myindex,
              "_type": "mytype",
              "_id": "1",
              "_score": 1,
              "_source": {
                  "f1": "396","f2": "142095","f3": "BH.705215.001",
                  "f4": "Proj1",
                  "f5": "BH.1511AI.001","f6": "","f7": "","f8": "","f9": "","f10": "","f11": "","f12": "","f13": "","f14": "","f15": "","f16": "09/05/16 | 01:02PM | User","deleted": "0"
              }
          //.......
          //.......
          //MANY RECORDS IN BETWEEN HERE
          //.......
          //.......
          }]
      }
  }
  </code></pre>
  
  <p>Any thing that I am doing wrong or missing? (Apologies for lengthy question, but I thought to give all possible information discarding unnecessary other code).</p>
  
  <p><strong>EDITED :</strong></p>
  
  <p>Term vector response</p>
  
  <pre><code>{
      "_index": "myindex",
      "_type": "mytype",
      "_id": "10",
      "_version": 1,
      "found": true,
      "took": 9,
      "term_vectors": {
          "f4": {
              "field_statistics": {
                  "sum_doc_freq": 5886,
                  "doc_count": 999,
                  "sum_ttf": 5886
              },
              "terms": {
                  "pr": {
                      "doc_freq": 999,
                      "ttf": 999,
                      "term_freq": 1,
                      "tokens": [{
                          "position": 0,
                          "start_offset": 0,
                          "end_offset": 6
                      }]
                  },
                  "pro": {
                      "doc_freq": 999,
                      "ttf": 999,
                      "term_freq": 1,
                      "tokens": [{
                          "position": 0,
                          "start_offset": 0,
                          "end_offset": 6
                      }]
                  },
                  "proj": {
                      "doc_freq": 999,
                      "ttf": 999,
                      "term_freq": 1,
                      "tokens": [{
                          "position": 0,
                          "start_offset": 0,
                          "end_offset": 6
                      }]
                  },
                  "proj1": {
                      "doc_freq": 111,
                      "ttf": 111,
                      "term_freq": 1,
                      "tokens": [{
                          "position": 0,
                          "start_offset": 0,
                          "end_offset": 6
                      }]
                  },
                  "proj10": {
                      "doc_freq": 11,
                      "ttf": 11,
                      "term_freq": 1,
                      "tokens": [{
                          "position": 0,
                          "start_offset": 0,
                          "end_offset": 6
                      }]
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p><strong>EDITED 2</strong></p>
  
  <p>Mappings for field f4</p>
  
  <pre><code>"f4" : {
      "type" : "string",
      "index_analyzer" : "myNGramAnalyzer",
      "search_analyzer" : "standard"
  }
  </code></pre>
  
  <p>I have updated to use standard analyzer for query time, which has improved the results but still not what I expected.</p>
  
  <p>Instead of 999 (all documents) now it return 111 documents like "Proj1", "Proj11", "Proj111"......"Proj1", "Proj181"......... etc.</p>
  
  <p>Still "Proj1" is in between the results and not at the top.</p>