简体   繁体   中英

Indexing files from sub directories in Lucene

I need to index files from two sub directory inside a main directory using Lucene.

Folder Structure

Main Folder

|---SubDirectory1

|---SubDirectory2

Tried this

String dataDir = "src\\\\main\\\\resources\\\\MainFolder";

I thought it will go inside sub directory and index the files in sub folders also but no, zero file indexed.

Is there any way do this/method in Lucene or should I create two indexes for each sub folder?

Lucene doesn't crawl through directories and index files for you. How would it know what attributes you want to index? That is something that you must do yourself. Have a look at the IndexFiles demo class provided by Apache in their tutorials for an example of how to do this. It might be worth copying the code into an IDE so it's easier to read, because there are a lot of comments in there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM