lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael McCandless <luc...@mikemccandless.com>
Subject Re: FileNotFoundException
Date Tue, 01 Aug 2006 17:20:20 GMT

> For the index process I use IndexModifier class.
> That happens when I try to search something into the index in the same
> time that the index process still running. 
> 
> the code for indexing:
> 	  System.setProperty("org.apache.lucene.lockDir", System
>                 .getProperty("user.dir"));
>         File folder = new File(getIndexPath());
>         Directory dir = null;
>         if (folder.isDirectory() && folder.exists()) {
>             dir = FSDirectory.getDirectory(getIndexPath(), false);
>         } else if (!folder.isFile() && !folder.exists()) {
>             dir = FSDirectory.getDirectory(getIndexPath(), true);
>         } else {
>             System.out.println("Bad index folder");
>             System.exit(1);
>         }
>         boolean newIndex = true;
>         if (dir.fileExists("segments")) {
>             newIndex = false;
>         }
>         // long lastindexation = dir.fileModified("segments");
>         writer = new IndexModifier(dir, new SimpleAnalyzer(), newIndex);
>         dir.close();
>         writer.setUseCompoundFile(true);
> 	  ...

BTW, one thing that I don't think is right is the "dir.close()" 
statement after you creat the IndexModifier.  I think you should not 
call dir.close() until you are done with the IndexModifier (ie, at the 
same time you call IndexModifier.close()).

It sounds like it's unrelated to your NFS locking issue but still could 
cause other problems...

Mike

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message