I have used the above code in the search module. Now the code works fine but i get the output as

390:File name is/home/maclean/Installations/apache-tomcat-7.0.21/logs/localhost_access_log.2012-12-31.txt
391:File name isnull
392:File name isnull
393:File name isnull
394:File name isnull
395:File name isnull
396:File name isnull
397:File name isnull
398:File name isnull
399:File name isnull
400:File name is/home/maclean/Installations/apache-tomcat-7.0.21/logs/localhost_access_log.2013-01-09.txt
401:File name isnull
402:File name isnull
403:File name isnull
404:File name isnull
405:File name isnull
406:File name isnull
407:File name isnull
408:File name isnull
409:File name isnull
410:File name is/home/maclean/Installations/apache-tomcat-7.0.21/logs/localhost_access_log.2013-01-10.txt

Here i am only printing the file names which have the query string yet i get too many results and most of the results have file name null why is this happening?

I recommend taking your index and opening it with Luke. It will show you the contents of the index. Maybe for the documents you have queried the file name is not set or not stored?
–
mindasMar 8 '13 at 9:45

Is it possible to print the line number as well as the entire line using lucene
–
Maclean PintoMar 8 '13 at 9:53