title: Elasticsearch 5.4 - filter by term if the term exists and don't filter when term is not present
body: <p>I'm searching on multiple types. One of the types returned has a field called my_field. The other types returned do not have that field. I want all results where the term does not exist and only the results where the field has the value True when the term does exist.</p>
  
  <p>It would be great if the filter on my_field didn't contribute to the query score and only filtered.</p>
  
  <p>This is as close as I got. I will self-flagellate for 1 hour if you help me please.</p>
  
  <p>(Don't use this it is wrong!)</p>
  
  <pre><code>body = {
      'query': {
          'bool': {
              'must': {
                  'multi_match': {
                      'query': 'pangolin',
                      'fields': ['_all', '_partials']
                  }
              },
              "should": {
                  "must_not": {
                      "exists": {
                          "field": "my_field"
                      }
                  }
              },
              "should": {
                  'term': {
                      'my_field': True
                  }
              }
          }
      }
  }
  </code></pre>