Created
January 19, 2011 18:19
-
-
Save ppearcy/786580 to your computer and use it in GitHub Desktop.
Script field failure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -XPUT 'http://localhost:9200/twitter/' | |
curl -XPUT 'http://localhost:9200/twitter/tweet/1' -d ' | |
{ | |
"attachmentcontent" : "test of script fields stuff" | |
} | |
' | |
curl -XPUT 'http://localhost:9200/twitter/tweet/2' -d ' | |
{ | |
"attachmentcontent" : "another test of script fields stuff" | |
} | |
' | |
# Fails because we use a local variable - Worked on 0.14.0, fails on 0.14.2 | |
curl -XGET http://localhost:9200/twitter/_search?pretty=True -d ' | |
{"from":0,"size":20,"query":{"query_string":{"query":"attachmentcontent:test","default_operator":"or"}},"script_fields":{"documentkey":{"script":"_source[fieldName]","params":{"fieldName":"documentkey"}},"attachmentcontent.fragment":{"script":"String blah = _source[fieldName];\nif (blah == null || blah.length() < fragmentSize) return blah;\nreturn blah.substring(0, fragmentSize);","params":{"fragmentSize":200,"fieldName":"attachmentcontent"}}},"highlight":{"pre_tags":["<WSODHighlight>"],"post_tags":["</WSODHighlight>"],"fields":{"attachmentcontent":{"fragment_size":200,"number_of_fragments":5}}}}' | |
# Succeeds, no local variable used | |
curl -XGET http://localhost:9200/twitter/_search?pretty=True -d ' | |
{"from":0,"size":20,"query":{"query_string":{"query":"attachmentcontent:test","default_operator":"or"}},"script_fields":{"documentkey":{"script":"_source[fieldName]","params":{"fieldName":"documentkey"}},"attachmentcontent.fragment":{"script":"if (_source[fieldName] == null || _source[fieldName].length() < fragmentSize) return _source[fieldName];\nreturn _source[fieldName].substring(0, fragmentSize);","params":{"fragmentSize":200,"fieldName":"attachmentcontent"}}},"highlight":{"pre_tags":["<WSODHighlight>"],"post_tags":["</WSODHighlight>"],"fields":{"attachmentcontent":{"fragment_size":200,"number_of_fragments":5}}}}' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment