POST'ing Search Template as REST API causes Elastic to fail on start


(Haruhiro Yoshimoto) #1

I'm using Elasticsearch 5.3.0, with java version "1.8.0_121", on Linux.
Also confirmed the same behavior with latest commit of 5.x and master branch.
Is this an intended behavior?

According to Pre Registered Templates, we can POST search template using REST API.
It works as expected.
However, when we restart the Elasticsearch after registering the template, it throws an exception.

Here's the step to reproduce.

  1. Download elasticsearch-5.3.0.tar.gz from official site, and unarchive it.
  2. Run elasticsearch using ./bin/elasticsearch
  3. Post search template using following command:
curl -H 'Content-Type:application/json' -X POST 'http://localhost:9200/_search/template/this_is_a_test' --data '{"template":{"query":{"match":{"title": "{{query_string}}"}}}}'

it returns
{"acknowledged":true}

  1. Quit Elasticsearch using Ctrl+C

  2. Start Elasticsearch using ./bin/elasticsearch

  3. The server fails to start with following stacktrace (only showing partial log):

[2017-04-17T17:55:36,116][ERROR][o.e.g.GatewayMetaState   ] [0i1Lvk1] failed to read local state, exiting...
org.elasticsearch.ElasticsearchException: java.io.IOException: failed to read [id:1, legacy:false, file:/home/my_user/Downloads/elasticsearch-5.3.0/data/nodes/0/_state/global-1.st]
	at org.elasticsearch.ExceptionsHelper.maybeThrowRuntimeAndSuppress(ExceptionsHelper.java:150) ~[elasticsearch-5.3.0.jar:5.3.0]
	at org.elasticsearch.gateway.MetaDataStateFormat.loadLatestState(MetaDataStateFormat.java:334) ~[elasticsearch-5.3.0.jar:5.3.0]
	at org.elasticsearch.gateway.MetaStateService.loadGlobalState(MetaStateService.java:113) ~[elasticsearch-5.3.0.jar:5.3.0]
Caused by: java.io.IOException: failed to read [id:1, legacy:false, file:/home/my_user/Downloads/elasticsearch-5.3.0/data/nodes/0/_state/global-1.st]
	at org.elasticsearch.gateway.MetaDataStateFormat.loadLatestState(MetaDataStateFormat.java:327) ~[elasticsearch-5.3.0.jar:5.3.0]
	... 46 more
Caused by: org.elasticsearch.common.ParsingException: [stored script source] failed to parse field [options]
	at org.elasticsearch.common.xcontent.ObjectParser.parseValue(ObjectParser.java:369) ~[elasticsearch-5.3.0.jar:5.3.0]
	at org.elasticsearch.common.xcontent.ObjectParser.parseSub(ObjectParser.java:378) ~[elasticsearch-5.3.0.jar:5.3.0]
	at org.elasticsearch.common.xcontent.ObjectParser.parse(ObjectParser.java:169) ~[elasticsearch-5.3.0.jar:5.3.0]
	... 46 more
Caused by: java.lang.IllegalArgumentException: content_type cannot be user-specified
	at org.elasticsearch.script.StoredScriptSource$Builder.setOptions(StoredScriptSource.java:127) ~[elasticsearch-5.3.0.jar:5.3.0]
	at org.elasticsearch.script.StoredScriptSource$Builder.access$100(StoredScriptSource.java:87) ~[elasticsearch-5.3.0.jar:5.3.0]
	at org.elasticsearch.script.StoredScriptSource.lambda$static$4(StoredScriptSource.java:163) ~[elasticsearch-5.3.0.jar:5.3.0]
	... 46 more

(nisha) #2

I am also getting the same exception


(Junzhe Ma) #3

I am also getting the same exception +1


(Colin Goodheart-Smithe) #4

This is indeed a bug and we are currently looking into it. You can track the progress here: https://github.com/elastic/elasticsearch/issues/24227


(system) #5

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.