{"action":"created","issue":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/26237","repository_url":"https://api.github.com/repos/elastic/elasticsearch","labels_url":"https://api.github.com/repos/elastic/elasticsearch/issues/26237/labels{/name}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/26237/comments","events_url":"https://api.github.com/repos/elastic/elasticsearch/issues/26237/events","html_url":"https://github.com/elastic/elasticsearch/issues/26237","id":250611946,"number":26237,"title":"script definition within percolator query is not consistent","user":{"login":"jmlucjav","id":1813237,"avatar_url":"https://avatars0.githubusercontent.com/u/1813237?v=4","gravatar_id":"","url":"https://api.github.com/users/jmlucjav","html_url":"https://github.com/jmlucjav","followers_url":"https://api.github.com/users/jmlucjav/followers","following_url":"https://api.github.com/users/jmlucjav/following{/other_user}","gists_url":"https://api.github.com/users/jmlucjav/gists{/gist_id}","starred_url":"https://api.github.com/users/jmlucjav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmlucjav/subscriptions","organizations_url":"https://api.github.com/users/jmlucjav/orgs","repos_url":"https://api.github.com/users/jmlucjav/repos","events_url":"https://api.github.com/users/jmlucjav/events{/privacy}","received_events_url":"https://api.github.com/users/jmlucjav/received_events","type":"User","site_admin":false},"labels":[{"id":356863226,"url":"https://api.github.com/repos/elastic/elasticsearch/labels/Pioneer%20Program","name":"Pioneer Program","color":"b60205","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-08-16T12:38:11Z","updated_at":"2017-08-16T17:03:48Z","closed_at":"2017-08-16T16:51:50Z","body":"**Elasticsearch version** \r\nVersion: 6.0.0-beta1-SNAPSHOT, Build: Unknown/2017-08-13T15:13:28.500Z, JVM: 1.8.0_102\r\n\r\n**JVM version**\r\njava version \"1.8.0_102\"\r\nJava(TM) SE Runtime Environment (build 1.8.0_102-b14)\r\nJava HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode)\r\n\r\n**OS version**\r\nwin10, 64b\r\n\r\n**Description of the problem including expected versus actual behavior**:\r\nThe same script definition that works on a _search request does not work when registering in a percolator query.\r\n\r\n**Steps to reproduce**:\r\n\r\n\r\n1. Create index: \r\n\r\n```\r\ncurl -XPUT http://localhost:9200/oneindex -H \"Content-Type: application/json\" -d '\r\n{\r\n    \"mappings\" : {\r\n       \"geoname\" : {\r\n        \"properties\" : {\r\n          \"name\" : {\"type\" : \"text\"},\r\n          \"population\" : {\"type\" :  \"long\"},\r\n          \"dem\" : {\"type\" :  \"long\"},\r\n                \"query\": {\r\n                    \"type\": \"percolator\"\r\n                }\r\n          }\r\n       }\r\n   } \r\n}'\r\n```\r\n\r\n2. Run a script query, define it as per the 6.0.0b1 docs, runs ok\r\n\r\n```\r\nQUERY=$(cat  << EOF\r\n{\r\n  \"query\": {\r\n        \"script\" : {\r\n            \"script\" : {\r\n                \"source\": \"doc['population'].value>(doc['dem'].value*100)\",\r\n                \"lang\": \"painless\"\r\n             }\r\n        }\r\n  }\r\n}\r\nEOF\r\n)\r\n\r\ncurl -XGET http://localhost:9200/oneindex/_search?pretty=true -H \"Content-Type: application/json\" -d \"$QUERY\"\r\n```\r\n\r\n3. Now try to register the percolator query using the same definition\r\n\r\n```\r\nQUERY=$(cat  << EOF\r\n{\r\n    \"query\":{  \r\n            \"script\" : {\r\n                \"source\": \"doc['population'].value>(doc['dem'].value*100)\",\r\n                \"lang\": \"painless\"\r\n                }\r\n      }\r\n}\r\nEOF\r\n)\r\n\r\ncurl -XPUT http://localhost:9200/oneindex/geoname/perc_bool?pretty=true -H \"Content-Type: application/json\" -d \"$QUERY\"\r\n```\r\n\r\nwe get: \r\n\r\n>     \"root_cause\" : [\r\n>       {\r\n>         \"type\" : \"parsing_exception\",\r\n>         \"reason\" : \"[script] query does not support [source]\",\r\n>         \"line\" : 4,\r\n>         \"col\" : 27\r\n\r\nafter I change 'source' to 'script' it still complains about 'lang'.\r\n\r\nif we do it this way, it works: \r\n\r\n```\r\nQUERY=$(cat  << EOF\r\n{\r\n    \"query\":{  \r\n        \"script\" : {\r\n            \"script\": \"doc['population'].value>(doc['dem'].value*100)\"\r\n            }\r\n      }\r\n}\r\nEOF\r\n)\r\n\r\ncurl -XPUT http://localhost:9200/oneindex/geoname/perc_bool?pretty=true -H \"Content-Type: application/json\" -d \"$QUERY\"\r\n```\r\n\r\n4. test percolator:\r\n```\r\n\r\ncurl -XGET http://localhost:9200/oneindex/_search?pretty=true -H \"Content-Type: application/json\" -d'\r\n{\r\n  \"query\": {\r\n    \"percolate\" : {\r\n      \"field\" : \"query\",\r\n      \"document\" : {\r\n        \"name\" : \"el lo li lo lu\",\r\n        \"population\" : 50000,\r\n        \"dem\" : 2\r\n      }\r\n    }\r\n  }\r\n}'\r\n\r\n\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/comments/322836455","html_url":"https://github.com/elastic/elasticsearch/issues/26237#issuecomment-322836455","issue_url":"https://api.github.com/repos/elastic/elasticsearch/issues/26237","id":322836455,"user":{"login":"jmlucjav","id":1813237,"avatar_url":"https://avatars0.githubusercontent.com/u/1813237?v=4","gravatar_id":"","url":"https://api.github.com/users/jmlucjav","html_url":"https://github.com/jmlucjav","followers_url":"https://api.github.com/users/jmlucjav/followers","following_url":"https://api.github.com/users/jmlucjav/following{/other_user}","gists_url":"https://api.github.com/users/jmlucjav/gists{/gist_id}","starred_url":"https://api.github.com/users/jmlucjav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmlucjav/subscriptions","organizations_url":"https://api.github.com/users/jmlucjav/orgs","repos_url":"https://api.github.com/users/jmlucjav/repos","events_url":"https://api.github.com/users/jmlucjav/events{/privacy}","received_events_url":"https://api.github.com/users/jmlucjav/received_events","type":"User","site_admin":false},"created_at":"2017-08-16T17:03:48Z","updated_at":"2017-08-16T17:03:48Z","body":"ah, that was the issue then, thanks!!"}}
{"actor":{"display_login":"jmlucjav"}}