Skip to content

Instantly share code, notes, and snippets.

@brwe
Last active September 23, 2017 04:17
Show Gist options
  • Save brwe/292681b8e4ab2612633f to your computer and use it in GitHub Desktop.
Save brwe/292681b8e4ab2612633f to your computer and use it in GitHub Desktop.
Significant terms examples, meetup "elasticsearch switzerland", June 5 2014
# Terms aggregations
POST reuters/_search
# aggregate on places - how many articles per country?
POST reuters-test/_search
{
"size": 0,
"aggregations": {
"class": {
"terms": {
"field": "places",
"size": 100
}
}
}
}
# aggregate on topics per country - what's the most important topic for each?
POST reuters/_search
{
"size": 0,
"aggregations": {
"places": {
"terms": {
"field": "places",
"size": 100
},
"aggs": {
"topics": {
"terms": {
"field": "topics",
"size": 10
}
}
}
}
}
}
# Aggregate words in body per country - which words most often used per country in the article?
# Not really useful, returns mostly stopwords
POST reuters/_search
{
"size": 0,
"aggregations": {
"class": {
"terms": {
"field": "places"
},
"aggs": {
"max_freq_terms": {
"terms": {
"field": "body",
"size": 10
}
}
}
}
}
}
# Significant terms in reuters
POST reuters/_search
{
"size": 0,
"aggregations": {
"class": {
"terms": {
"field": "places"
},
"aggregations": {
"sig_terms": {
"significant_terms": {
"field": "body"
}
}
}
}
}
}
# Significant terms for movie reviews
POST movie-reviews/_search
# what are the most often used words in positive and negative reviews?
# Not really useful, returns mostly stopwords
POST movie-reviews/_search
{
"size": 0,
"aggregations": {
"class": {
"terms": {
"field": "class"
},
"aggregations": {
"sig_terms": {
"terms": {
"field": "text"
}
}
}
}
}
}
# Now, use significant terms for that
POST movie-reviews/_search
{
"size": 0,
"aggregations": {
"class": {
"terms": {
"field": "class"
},
"aggregations": {
"sig_terms": {
"significant_terms": {
"field": "text"
}
}
}
}
}
}
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@brwe
Copy link
Author

brwe commented Jul 5, 2014

Significant terms for movie recommendations were missing the background filter. Added this in revision 2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment