title: Match and highlight documents using different queries for different fields in ElasticSearch
body: <p>My objective is to create a query which will find the "best" 20 documents using a normal <code>query_string</code> query on fields A, B, and C of a document and trying to do an exact or exact-subset match on field D. For example: if field D is 'AAA.BBB.CCC.DDD' then queries for "AAA.BBB" should match (and "BBB.CCC", and "AAA.BBB.CCC", etc). Oh yeah, I'd also like to have the highlighted results.</p>
  
  <p>My closest attempt to date is to use an ngram tokenizer/analyzer on field D and just allowing A, B, C to be indexed as normal.</p>
  
  <pre><code>{
      "settings": {
          "number_of_shards": 5,
          "index": {
              "analysis": {
                  "tokenizer": {
                      "customNgram": {
                          "type": "nGram",
                          "min_gram": "3",
                          "max_gram": "5"
                      }
                  },
                  "analyzer": {
                      "lllNgram": {
                          "type": "custom",
                          "filter": "lowercase",
                          "tokenizer": "customNgram"
                      }
                  }
              }
          }
      },
      "mappings": {
          "lessons": {
              "_id": {
                  "path": "id"
              },
              "properties": {
                  "id": {
                      "type": "integer"
                  },
                  "A": {
                      "type": "string",
                      "store": "yes"
                  },
                  "B": {
                      "type": "string",
                      "store": "yes"
                  },
                  "C": {
                      "type": "string",
                      "store": "yes"
                  },
                  "D": {
                      "type": "string",
                      "store": "yes",
                      "analyzer": "lllNgram"
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>Then using a query like so:</p>
  
  <pre><code>{
      "size":20,
      "query":{
          "filtered":{
              "query":{
                  "match_all":{}
              },
              "filter":{
                  "or":[
                      {
                          "query":{
                              "query_string":{
                                  "query":"XYZZY TOP",
                                  "fields":["A","B","C"]
                              }
                          }
                      },
                      {
                          "query":{
                              "match":{
                                  "D": {
                                      "query":"XYZZY TOP",
                                      "operator" : "and"
                                  }
                              }
                          }
                      }
                  ]
              }
           }
      },
      "highlight":{
          "pre_tags":["&lt;em&gt;"],
          "post_tags":["&lt;\/em&gt;"],
          "fields":{
              "A":{},
              "B":{},
              "C":{},
              "D":{}
          }
      }
  }
  </code></pre>
  
  <p>The problem with this is that field D seems to never match anything... ever... no matter what. The resultset also does not contain any highlighting with this query.</p>
  
  <p>SO, please help me to understand what I have done wrong in my query.</p>