title: Find count of given words in Java Lucene library
body: <p>In the tutorial of Lucene ( <a href="http://www.lucenetutorial.com/lucene-in-5-minutes.html" rel="nofollow">http://www.lucenetutorial.com/lucene-in-5-minutes.html</a> ), </p>
  
  <pre><code>public class HelloLucene {
  public static void main(String[] args) throws IOException, ParseException {
  IndexWriter w = new IndexWriter(index, config);
           addDoc(w, "Lucene lucene in Action");
           addDoc(w, "Lucene for Dummies");
           addDoc(w, "Managing Gigabytes");
           addDoc(w, "The Art of Computer Science");
           w.close();
  String querystr = args.length &gt; 0 ? args[0] : "lucene";
  //...
   }
  }
  </code></pre>
  
  <p>When I change as indicated above the string to "Lucene lucene in Action", then search the doc for keyword "lucene", it finds the number of hits 1 for the string "Lucene lucene in Action". I want to send a string (e.g. "asd asd fds asd") to function and search for "asd" and find the result 3. How can I do that by using the query addDoc(w, "asd asd fds asd"); ???</p>
  
  <p>It does not giving the number of hits in selected line. It writes 1 if there is a hit or hits, and 0 if there is not.</p>