elasticsearch/elasticsearch — pull request #8393 by lukas-vlcek (2014-11-07 17:16:36+00:00)
Title: Search Template - parse template if it is provided as a single escaped string.

I was trying to implement fix for #8308

I think I nailed it down. It seems it is combination of two related issues:

1) The `TemplateQueryParser.java` was not correctly parsing the request when the `template` contained a single `VALUE_STRING` token. I think this could not have been working before (obviously there were no tests for this use case). I improved the main `parse` method to detect string token. **Please review** namely the complex `if` conditions - I am sure there is a way how to express them in more elegant way.

2) The second issue is with `SearchService.java` in `parseTemplate` method where it tries to parse the template for second time. When I commented this part out then all the tests that I added to `TemplateQueryTest.java` started to pass. **Please review** validity of commenting this out. I did not notice any tests that would be broken due to this but the chance is that there were no tests covering the logic behind second parsing pass.

Looking for the feedback.