Last active
August 29, 2015 14:07
-
-
Save thibault/f4462bf856d82174f94c to your computer and use it in GitHub Desktop.
Testing script_fields and _source
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
# (Re)create the index | |
curl -X DELETE 'http://localhost:9200/script-fields-test/' | |
curl -X PUT 'http://localhost:9200/script-fields-test/' | |
# Index documents | |
curl -X POST 'http://localhost:9200/script-fields-test/d/1' -d '{"title":"Title1", "count":1}' | |
curl -X POST 'http://localhost:9200/script-fields-test/d/2' -d '{"title":"Title1", "count":2}' | |
curl -X POST 'http://localhost:9200/script-fields-test/_refresh' |
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 -X GET 'http://localhost:9200/script-fields-test/_search?pretty=true' -d ' | |
{ | |
"query" : { "match_all" : {} }, | |
"script_fields" : { | |
"my_count" : { | |
"script" : "doc[\"count\"].value * factor", | |
"params" : { | |
"factor" : 2 | |
} | |
} | |
} | |
} | |
' |
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
{ | |
"took" : 3, | |
"timed_out" : false, | |
"_shards" : { | |
"total" : 5, | |
"successful" : 5, | |
"failed" : 0 | |
}, | |
"hits" : { | |
"total" : 2, | |
"max_score" : 1.0, | |
"hits" : [ { | |
"_index" : "script-fields-test", | |
"_type" : "d", | |
"_id" : "1", | |
"_score" : 1.0, | |
"fields" : { | |
"my_count" : [ 2 ] | |
} | |
}, { | |
"_index" : "script-fields-test", | |
"_type" : "d", | |
"_id" : "2", | |
"_score" : 1.0, | |
"fields" : { | |
"my_count" : [ 4 ] | |
} | |
} ] | |
} | |
} |
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 -X GET 'http://localhost:9200/script-fields-test/_search?pretty=true' -d ' | |
{ | |
"query" : { "match_all" : {} }, | |
"fields" : ["_source"], | |
"script_fields" : { | |
"my_count" : { | |
"script" : "doc[\"count\"].value * factor", | |
"params" : { | |
"factor" : 2 | |
} | |
} | |
} | |
} | |
' |
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
{ | |
"took" : 2, | |
"timed_out" : false, | |
"_shards" : { | |
"total" : 5, | |
"successful" : 5, | |
"failed" : 0 | |
}, | |
"hits" : { | |
"total" : 2, | |
"max_score" : 1.0, | |
"hits" : [ { | |
"_index" : "script-fields-test", | |
"_type" : "d", | |
"_id" : "1", | |
"_score" : 1.0, | |
"_source":{"title":"Title1", "count":1}, | |
"fields" : { | |
"my_count" : [ 2 ] | |
} | |
}, { | |
"_index" : "script-fields-test", | |
"_type" : "d", | |
"_id" : "2", | |
"_score" : 1.0, | |
"_source":{"title":"Title1", "count":2}, | |
"fields" : { | |
"my_count" : [ 4 ] | |
} | |
} ] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment