title: How to get counter of each word in windowed stream on Flink
body: <p>I want to get the count of words with windowed function for each word:</p>
  
  <p>If I use this code :</p>
  
  <pre><code>object WindowWordCount {
    def main(args: Array[String]) {
  
      val env = StreamExecutionEnvironment.getExecutionEnvironment
      val text = env.socketTextStream("localhost", 9999)
  
      val counts = text.flatMap { _.toLowerCase.split("\\W+") filter { _.nonEmpty } }
        .map { (_, 1) }
        .keyBy(0)
        .timeWindow(Time.seconds(5))
        .sum(1)
  
      counts.print
  
      env.execute("Window Stream WordCount")
    }
  }
  </code></pre>
  
  <p>I get output after 5 seconde (windowed time) like this:</p>
  
  <p>input:</p>
  
  <pre><code>first input : hello
  seconde input : hello
  third input : word
  fifth input : hello
  sixth input : word
  </code></pre>
  
  <p>output</p>
  
  <pre><code>first output : hello : 3 | word : 2
  </code></pre>
  
  <p>but I want to have the output with count for every word.</p>
  
  <p>like that :
  input:</p>
  
  <pre><code>first input: hello
  seconde input:hello
  third input:word
  fifth input:hello
  sixth input:word
  </code></pre>
  
  <p>out put:</p>
  
  <pre><code>first output: hello : 1
  seconde output:hello : 2
  third output:word : 1
  fifth output:hello : 3
  sixth output:word : 2
  </code></pre>
  
  <p>how can I do this ?</p>