title: How to do a masked query in Elasticsearch?
body: <p>For example, I am storing user passports in Elasticsearch. They are stored as consecutive letters and digits of the following format: <code>AADDDDDDD</code>. 2 alphabet and then 7 digits.</p>
  
  <p>User is interested in search where he could mention specific values for specific positions. For example, I want to search all the passport numbers who have 'A' at the beginning, '7' in the third position and '0' in the last position. Something like this:</p>
  
  <pre><code>A-7----0
  </code></pre>
  
  <p>How to generate an efficient query for this? Do I need to create any custom analyzer for this?</p>
  
  <p>So far what I've done is I inserted space in between characters and then searching for index position, seems like a costly operation to me.</p>