Q:

Elastic Search | How to get original search query with corresponding match value

I'm using ElasticSearch as search engine for a human resource database.
The user submits a competence (f.ex 'disruption'), and ElasticSearch returns all users ordered by best match.
I have configured the field 'competences' to use synonyms, so 'innovation' would match 'disruption'.
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 explain api (reference)
The query works as expected and returns an _explanation to each hit.
Details (simplified a bit) for a particular hit could look like the following:
{
   description: "weight(Synonym(skills:innovation skills:disruption)),
   value: 3.0988
}

Problem: I cannot see what the original search term was in the _explanation. (As illustrated in example above: I can see that some search query matched with 'innovation' or 'disruption', I need to know what the skill the users searched for)
Question: Is there any way to solve this issue (example: parse a custom 'description' with info about the search query tag to the _explanation)? 
Expected Result:
{
   description: "weight(Synonym(skills:innovation skills:disruption)),
   value: 3.0988
   customDescription: 'innovation'
}

A:

Maybe you can put the original query in the _name field?
Like explained in https://qbox.io/blog/elasticsearch-named-queries:
GET /_search
{
    "query": {
        "query_string" : {
            "default_field" : "skills",
            "query" : "disruption",
            "_name": "disruption"
        }
    }
}

You can then find the proginal query in the matched queries section in the return object:
{
  "_index": "testindex",
  "_type": "employee",
  "_id": "2",
  "_score": 0.19178301,
  "_source": {
    "skills": "disruption"
  },
  "matched_queries": [
    "disruption"
  ]
}

Add the explain to the solution and i think it would work fine...?

