Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6115175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:03:38+00:00 2026-05-23T15:03:38+00:00

I’m working on a small lucene project, where i have to index a bunch

  • 0

I’m working on a small lucene project, where i have to index a bunch of text files. so far i’ve managed to create the index, i think. the code runs and i get a bunch of files called 0_.* fdt/fdx/fnm and more.

what i want to know is, can i pick a destination folder, for the index to be created in?

i’m following this Guide and i define a index folder, and a files to index folder, but i can’t find any parameters in the indexwriter constructor, that could achieve this.

here’s my code for creating the index

public static void createIndex() throws CorruptIndexException, LockObtainFailedException, IOException {
    File[] files = FILES_TO_INDEX_DIRECTORY.listFiles();
    Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_33);
    SimpleFSDirectory d = new SimpleFSDirectory(FILES_TO_INDEX_DIRECTORY);
    IndexWriter indexWriter = new IndexWriter(d, analyzer, IndexWriter.MaxFieldLength.LIMITED);

    for (File file : files) {
        Document document = new Document();

        String path = file.getCanonicalPath();
        byte[] bytes = path.getBytes();
        document.add(new Field(FIELD_PATH, bytes));

        Reader reader = new FileReader(file);
        document.add(new Field(FIELD_CONTENTS, reader));

        indexWriter.addDocument(document);
    }
    indexWriter.optimize();
    indexWriter.close();
}

and i’m using type File instead of string for the directories

public static File FILES_TO_INDEX_DIRECTORY = new File("C:\\Users\\k\\Dropbox\\Public\\afgansprojekt\\RouteLogger\\Lucene\\FilesToIndex");
public static final File INDEX_DIRECTORY = new File("C:\\Users\\k\\Dropbox\\Public\\afgansprojekt\\RouteLogger\\Lucene\\Index");
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T15:03:39+00:00Added an answer on May 23, 2026 at 3:03 pm

    Actually you are setting the destination folder with SimpleFSDirectory d = new SimpleFSDirectory(FILES_TO_INDEX_DIRECTORY);

    Just change SimpleFSDirectory(FILES_TO_INDEX_DIRECTORY); to SimpleFSDirectory(INDEX_DIRECTORY);.

    Edit:

    File[] files = FILES_TO_INDEX_DIRECTORY.listFiles(); //this is where you set the files to index
    
    SimpleFSDirectory d = new SimpleFSDirectory(FILES_TO_INDEX_DIRECTORY); //here you are setting the index directory
    

    You should change this line to SimpleFSDirectory d = new SimpleFSDirectory(INDEX_DIRECTORY);

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bunch of posts stored in text files formatted in yaml/textile (from
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a small JavaScript validation script that validates inputs based on Regex. I
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have an array which has BIG numbers and small numbers in it. I
I have a text area in my form which accepts all possible characters from
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I have thousands of HTML files to process using Groovy/Java and I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.