Skip to content

Instantly share code, notes, and snippets.

@clintongormley
Created March 21, 2013 18:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clintongormley/5215358 to your computer and use it in GitHub Desktop.
Save clintongormley/5215358 to your computer and use it in GitHub Desktop.
curl -XGET 'http://127.0.0.1:9200/events/event/_search?pretty=1' -d '
{
"query" : {
"nested" : {
"filter" : {
"bool" : {
"must" : [
{
"term" : {
"tags.type" : "company"
}
},
{
"term" : {
"tags.value" : "Google"
}
}
]
}
},
"path" : "tags"
}
},
"facets" : {
"speaker" : {
"terms_stats" : {
"order" : "total",
"key_field" : "value",
"value_field" : "weight"
},
"facet_filter" : {
"term" : {
"tags.type" : "speaker"
}
},
"nested" : "tags"
},
"place" : {
"terms_stats" : {
"order" : "total",
"key_field" : "value",
"value_field" : "weight"
},
"facet_filter" : {
"term" : {
"tags.type" : "place"
}
},
"nested" : "tags"
},
"company" : {
"terms_stats" : {
"order" : "total",
"key_field" : "value",
"value_field" : "weight"
},
"facet_filter" : {
"term" : {
"tags.type" : "company"
}
},
"nested" : "tags"
}
}
}
'
# [Thu Mar 21 19:17:26 2013] Response:
# {
# "hits" : {
# "hits" : [
# {
# "_source" : {
# "title" : "Paris in the springtime",
# "tags" : [
# {
# "value" : "Paris",
# "weight" : 10,
# "type" : "place"
# },
# {
# "value" : "Eric Schmidt",
# "weight" : 100,
# "type" : "speaker"
# },
# {
# "value" : "Google",
# "weight" : 50,
# "type" : "company"
# }
# ]
# },
# "_score" : 1,
# "_index" : "events",
# "_id" : "q8iOOADTTNSkapd5_zuUuA",
# "_type" : "event"
# }
# ],
# "max_score" : 1,
# "total" : 1
# },
# "timed_out" : false,
# "_shards" : {
# "failed" : 0,
# "successful" : 5,
# "total" : 5
# },
# "facets" : {
# "speaker" : {
# "terms" : [
# {
# "count" : 1,
# "min" : 100,
# "max" : 100,
# "mean" : 100,
# "total" : 100,
# "total_count" : 1,
# "term" : "Eric Schmidt"
# }
# ],
# "missing" : 0,
# "_type" : "terms_stats"
# },
# "place" : {
# "terms" : [
# {
# "count" : 1,
# "min" : 10,
# "max" : 10,
# "mean" : 10,
# "total" : 10,
# "total_count" : 1,
# "term" : "Paris"
# }
# ],
# "missing" : 0,
# "_type" : "terms_stats"
# },
# "company" : {
# "terms" : [
# {
# "count" : 1,
# "min" : 50,
# "max" : 50,
# "mean" : 50,
# "total" : 50,
# "total_count" : 1,
# "term" : "Google"
# }
# ],
# "missing" : 0,
# "_type" : "terms_stats"
# }
# },
# "took" : 4
# }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment