title: Search for two fields but only score once in Elasticsearch
body: <p>Let's say I have these documents in Elasticsearch:</p>
  <pre><code>{
      &quot;display_name&quot;: &quot;Jose Cummings&quot;,
      &quot;username&quot;: &quot;josecummings&quot;
  },
  {
      &quot;display_name&quot;: &quot;Jose Ramirez&quot;,
      &quot;username&quot;: &quot;elite_gamer&quot;
  },
  {
      &quot;display_name&quot;: &quot;Lance Abrams&quot;,
      &quot;username&quot;: &quot;abrams1&quot;
  },
  {
      &quot;display_name&quot;: &quot;Steve Smith&quot;,
      &quot;username&quot;: &quot;josesmose&quot;
  }
  </code></pre>
  <p>I want to run a &quot;as you type&quot; search for <code>Jose</code> that searches against both the <code>display_name</code> and the <code>username</code> fields, which I can do with this:</p>
  <pre><code>{
      &quot;query&quot;: {
          &quot;bool&quot;: {
              &quot;must&quot;: {
                  &quot;multi_match&quot;: {
                      &quot;fields&quot;: [
                          &quot;display_name&quot;,
                          &quot;username&quot;
                      ],
                      &quot;query&quot;: &quot;Jose&quot;,
                      &quot;type&quot;: &quot;bool_prefix&quot;,
                      &quot;fuzziness&quot;: &quot;AUTO&quot;,
                      &quot;boost&quot;: 50
                  }
              }
          }
      }
  }
  </code></pre>
  <p>The issue here is that when I search for <code>Jose</code>, Jose Cummings gets 100 points while Jose Ramirez and Steve Smith only get 50 points, because it seems to sum the scores for the two fields. This essentially rewards a user for having the same <code>display_name</code> as <code>username</code>, which we do not want to happen.</p>
  <p>Is there a way to only take the max score from the two fields? I've tried dozens of different combinations now using <code>function_score</code>, <code>boost_mode</code>/<code>score_mode</code>, <code>constant_score</code>, trying to do a <code>should</code> match with multiple <code>match_bool_prefix</code> queries, etc. Nothing I've tried seems to achieve this.</p>