Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

search content in a file , file search  RSS feed

 
prince davies
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



I have no idea what modification do I need to make in order to search through all files irespective of their extention? In this example, it has specified the suffix as xml. This will index only the files with xml extention. Its a limitation to the program. How do I over come this limitation?
 
prince davies
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
add lucene-core-3.5.0.jar in classpath
 
Tim McGuire
Ranch Hand
Posts: 820
IntelliJ IDE Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you made the String suffix equal "xml" in the main method of SimpleFileIndexer

later on, this bit:



will make it skip any files except those that end with suffix . Why is it there and what happens if you get rid of this block?
 
prince davies
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you made the String suffix equal "xml" in the main method of SimpleFileIndexer

later on, this bit:

view plaincopy to clipboardprint?
if (suffix!=null && !f.getName().endsWith(suffix)) {
return;
}


I grab this example from a website. They used lucene as a search engine and its very quick and clean. So I thought of trying it for my requirement.But here the issue is I need to provide file extension or format as suffix. It s a limitation to my requirement. I never worked on lucene search egine. If you have any idea , please let me know
 
prince davies
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is the website , from which i got this program

http://www.javacodegeeks.com/2010/05/introduction-to-apache-lucene-for-full.html
 
Tim Moores
Saloon Keeper
Posts: 3834
80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you missed Tim's point: there's currently code that restricts the indexing to a particular suffix. If that's not what you want, just remove that code. That doesn't even have anything to do with Lucene.
 
Tim McGuire
Ranch Hand
Posts: 820
IntelliJ IDE Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
prince davies wrote:

I grab this example from a website. They used lucene as a search engine and its very quick and clean. So I thought of trying it for my requirement.But here the issue is I need to provide file extension or format as suffix. It s a limitation to my requirement. I never worked on lucene search egine. If you have any idea , please let me know



can you take another look at the following code and write what you think it does?

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!