1

I have a problem Im not sure how to solve.

Imagine i have some tweets from different users and would like to know which words are used the most for a specific user. To make it more interesting, Id like to boost the count by how unique the word is in the context of all tweets (from all users).

So, lets say that one user has tweeted the word "stackoverflow" four times in total and that "stackoverflow" has only been used by that user. The same user has also tweeted the words "I", "for" and "yes" several times more (say 10), but those words has also been tweeted by loads of other users plenty of times.

I'd like to find a query that would boost the count/score of "stackoverflow" higher than the count/score of, lets say, "for".

The elasticsearch type in this case would contain a string with the full tweet ("tweet"), an unanalyzed array with the words used in the tweet ("tweetedWords") and the name of the user ("user").

Any ideas?

1 Answer 1

2

After finding the right google-keyword ("elasticsearch aggregate on frequency"), I found what I was looking for: significant_terms.

{
  "query" : {
    "terms": {"user": ["{user}"]}
  },
  "size": 0,
  "aggs": {
    "tweetedWords": {
      "significant_terms": {
        "field": "tweetedWords"
      }
    }
  }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.