Skip to content

Instantly share code, notes, and snippets.

@dadoonet
Created November 28, 2013 10:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dadoonet/7689977 to your computer and use it in GitHub Desktop.
Save dadoonet/7689977 to your computer and use it in GitHub Desktop.
Test doc field existence in elasticsearch facet script
curl -XDELETE "http://localhost:9200/script/"
curl -XPUT "http://localhost:9200/script/doc/1" -d'
{
"title":"test"
}'
curl -XPUT "http://localhost:9200/script/doc/2?refresh" -d'
{
"title":"nothing",
"test":"value"
}'
curl -XPOST "http://localhost:9200/script/_search?size=0&pretty" -d'
{
"facets": {
"mime_type": {
"terms": {
"script": "doc[\"test\"].empty ? null : _source.test"
}
}
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment