title: Elastic Search | How to get original search query with corresponding match value
body: <p>I'm using ElasticSearch as search engine for a human resource database.</p>
  
  <p>The user submits a competence (f.ex 'disruption'), and ElasticSearch returns all users ordered by best match.</p>
  
  <p>I have configured the field 'competences' to use synonyms, so 'innovation' would match 'disruption'.</p>
  
  <p>I want to show the user (who is performing the search) how a particular search result matched the search query. For this I use the <code>explain</code> api (<a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-explain.html" rel="nofollow noreferrer">reference</a>)</p>
  
  <p>The query works as expected and returns an <code>_explanation</code> to each <code>hit</code>.
  Details (simplified a bit) for a particular hit could look like the following:</p>
  
  <pre><code>{
     description: "weight(Synonym(skills:innovation skills:disruption)),
     value: 3.0988
  }
  </code></pre>
  
  <p><strong>Problem:</strong> I cannot see what the original search term was in the <code>_explanation</code>. (As illustrated in example above: I can see that <em>some</em> search query matched with 'innovation' or 'disruption', I need to know what the skill the users searched for)</p>
  
  <p><strong>Question:</strong> Is there any way to solve this issue (example: parse a custom 'description' with info about the search query tag to the <code>_explanation</code>)? </p>
  
  <p><strong>Expected Result:</strong></p>
  
  <pre><code>{
     description: "weight(Synonym(skills:innovation skills:disruption)),
     value: 3.0988
     customDescription: 'innovation'
  }
  </code></pre>