Skip to content

Instantly share code, notes, and snippets.

@craigeddy
Last active April 7, 2023 11:56
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 craigeddy/ff51f0d207ec15cb64ce1d9bafe1edcc to your computer and use it in GitHub Desktop.
Save craigeddy/ff51f0d207ec15cb64ce1d9bafe1edcc to your computer and use it in GitHub Desktop.
Elasticsearch query that creates a word cloud from a partition of social media posts
GET posts/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"partitionKey.keyword": "9e6f80e6-d834-4d63-a37d-1845e90b4007"
}
},
{
"terms": {
"postType": ["Like", "Post", "Reply", "Repost"]
}
}
]
}
},
"size": 0,
"aggs": {
"cloud": {
"terms": {
"field": "content.stop",
"size": 20
},
"aggs": {
"avg_sentiment": {
"avg": {
"field": "sentiment"
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment