Skip to content

Failed to derive xcontent on template queries #9458

@micpalmia

Description

@micpalmia

With ES 1.4 on my local (iOS) machine with all the default settings, I get a SearchPhaseExecutionException when trying to execute a template query.

Please find the described steps below.

# store the search template
curl -XPUT "http://localhost:9200/_search/template/testSearch" -d'
{
    "template": {"query": {"match_all": {}}}
}'

# it seems to be correctly stored
curl -XGET "http://localhost:9200/_search/template/testSearch"

# using the template endpoint works fine
curl -XGET "http://localhost:9200/.scripts/_search/template" -d'
{
    "template": {
        "id": "testSearch" 
    }
}'

# but using a completely equivalent template query doesn't
curl -XGET "http://localhost:9200/.scripts/_search" -d'
{
    "query": {
        "template": {
            "query": "testSearch", 
            "params" : {}
        }
    }
}'

Please find the complete stack trace below

[2015-01-28 12:35:20,513][DEBUG][action.search.type       ] [Yukon Jack] [.scripts][0], node[Yax3V7rFQt2UQcQoYfDy-Q], [P], s[STARTED]: Failed to execute [org.elasticsearch.action.search.SearchRequest@2c968bee]
org.elasticsearch.search.SearchParseException: [.scripts][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{
    "query": {
        "template": {
            "query": "testSearch",
            "params" : {}
        }
    }
}
]]
    at org.elasticsearch.search.SearchService.parseSource(SearchService.java:681)
    at org.elasticsearch.search.SearchService.createContext(SearchService.java:537)
    at org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:509)
    at org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:350)
    at org.elasticsearch.search.action.SearchServiceTransportAction$11.call(SearchServiceTransportAction.java:333)
    at org.elasticsearch.search.action.SearchServiceTransportAction$11.call(SearchServiceTransportAction.java:330)
    at org.elasticsearch.search.action.SearchServiceTransportAction$23.run(SearchServiceTransportAction.java:559)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.elasticsearch.ElasticsearchParseException: Failed to derive xcontent from org.elasticsearch.common.bytes.PagedBytesReference@fb05139b
    at org.elasticsearch.common.xcontent.XContentFactory.xContent(XContentFactory.java:259)
    at org.elasticsearch.index.query.TemplateQueryParser.parse(TemplateQueryParser.java:85)
    at org.elasticsearch.index.query.QueryParseContext.parseInnerQuery(QueryParseContext.java:277)
    at org.elasticsearch.index.query.IndexQueryParserService.innerParse(IndexQueryParserService.java:382)
    at org.elasticsearch.index.query.IndexQueryParserService.parse(IndexQueryParserService.java:281)
    at org.elasticsearch.index.query.IndexQueryParserService.parse(IndexQueryParserService.java:276)
    at org.elasticsearch.search.query.QueryParseElement.parse(QueryParseElement.java:33)
    at org.elasticsearch.search.SearchService.parseSource(SearchService.java:665)
    ... 9 more
[2015-01-28 12:35:20,515][DEBUG][action.search.type       ] [Yukon Jack] All shards failed for phase: [query_fetch]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions