title: ElasticSearch: (OR) wildcard on two fields AND match exactly one
body: <p>I am <em>very</em> new to the Elastic world and I am having a lot of troubles understand the logic behind some operations.
  Currently studying and trying a lot of stuff, so I am a bit confused right now and I need some hints.</p>
  
  <p>The scenario.
  I have the following (<code>client</code> type) documents in the <code>clients</code> index (don't worry: the names are football players and the phone numbers are not real):</p>
  
  <pre><code>    {
        "firstName" : "Alessandro",
        "lastName" : "Nesta",
        "phoneNumber" : "+3949304903",
        "merchantId" : "90339203812831293"
      },
      {
        "firstName" : "Alessandro",
        "lastName" : "Del Piero",
        "phoneNumber" : "+39129302902",
        "merchantId" : "90339203812831293"
      },
      {
        "firstName" : "Alessandro",
        "lastName" : "Costacurta",
        "phoneNumber" : "+39098921321",
        "merchantId" : "1239021392839238"
      }
  </code></pre>
  
  <p>Now, the search query I am looking for basically does this: given a <code>merchantId</code> and a query string, try to find the query string inside firstName or inside lastName, but be sure that merchantId is exactly like the one passed in the query.</p>
  
  <p>Let's say I have a query string "Aless" and a merchantId "90339203812831293 ", in the SQL world I was going to do:</p>
  
  <pre><code>SELECT
  *
  FROM
    `clients`
  WHERE
    `merchantId` = "90339203812831293"
  AND 
  (
    `firstName` LIKE "Aless%" OR `lastName` LIKE "Aless%"
  );
  </code></pre>
  
  <p>And the results should be:</p>
  
  <pre><code>{
    "firstName" : "Alessandro",
    "lastName" : "Nesta",
    "phoneNumber" : "+3949304903",
    "merchantId" : "90339203812831293"
  },
  {
    "firstName" : "Alessandro",
    "lastName" : "Del Piero",
    "phoneNumber" : "+39129302902",
    "merchantId" : "90339203812831293"
  }
  </code></pre>
  
  <p>What I have tried? Basically different from combinations, from putting the merchantId in the filter section, to multi_match.</p>
  
  <pre><code>{
  "query": {
    "bool": {
      "should": [
        {
          "wildcard": {
            "firstName": "aless*"
          }
        },
        {
          "wildcard": {
            "lastName": "aless*"
          }
        }
      ],
      "must": {
        "match": {
          "merchantId": "90339203812831293"
        }
      }
    }
  }
  </code></pre>
  
  <p>0 results (If I remove the merchantId part works fine).</p>
  
  <p>I have tried with query strings, too:</p>
  
  <pre><code>{
  "query": {
    "bool": {
      "must": {
        "query_string": {
          "query": "Del*",
          "fields": [
            "firstName",
            "lastName"
          ]
        }
      },
      "filter": {
        "term": {
          "merchantId": "90339203812831293"
        }
      }
    }
  }
  }
  </code></pre>
  
  <p>Same problem.
  Can you please me point to what I am doing wrong?
  Thanks in advance!</p>