just for the archives in case anyone else runs into this..

i had my lucene implementations index to a different directory allowing the 
searcher to work over the previous one while the index built the new one.   
then at the eend of building the new one, the indexing code would tell the 
searcher to use the new directory, and procede to delete any other directory it 
found in that area, representing any previous indexes.   this worked fine on 
osX for the g4 and g5 i was using.   on the server, running windows2003server, 
this didnt work.   the code i pasted for the delete was bad and it was deleting 
everything.  HOWEVEr, on the non-ms-server os's, the deleting couldnt get rid 
of the active files.   on the windows server os, it was able to delete 
"segments" and none of the others.   so it lies between the different os's 
various' ways of seeing: lock, busy, inactive files and what lucene is doing 
with the segment (and other really) files at that moment.   and all this was 
brought by dumb code that allowed the attempted deletion of the current index 
anyway.   it just made it to the staging server because the other os's didn't 
have this problem.    so, live and learn!




-----Original Message-----
From: John Powers [mailto:[EMAIL PROTECTED]
Sent: Sat 1/28/2006 9:13 PM
To: java-user@lucene.apache.org
Subject: RE: problem updating a document: no segments file?
 
i feel confident in the delete sequence.  i will run the things you ask for 
though.    this does work on my laptop.   

the code that changed was some update method that was used in the first 
release.   so before the only writes needed were done by this and it wholesale 
replaces.   whereas the new feature updates documents.   it worked fine in 
testing.   and i look at the product of this method in other environments and 
they all have segment files and update fine.       i do appreciate your 
response though.  at least i have things to do to move this forward now.  i 
will print out all the paths that get touched by this delete block, and the 
results of ech delete().    its good to get rid of possibilities.

baring this being the problem..   what would cause lucene to delete its segment 
file?

--JN

: :                     if (!newPath.equals(subDirs[i].getPath())) {


part keeps it out of the new path.     no, the boxes have different windows 
operating systems.    probobly a slight difference in jvm.


-----Original Message-----
From: [EMAIL PROTECTED] on behalf of Chris Hostetter
Sent: Sat 1/28/2006 2:37 AM
To: java-user@lucene.apache.org
Subject: RE: problem updating a document: no segments file?
 

: this code works in a couple other boxes as is.  that deleting code

Are those boxes running the same OS?  The same JVM?

: removes the active index after this one builds in a different location.
: then the searcher is told to make this newest one the current and the
: old one is deleted.  it effects directories and their entire contents.
: it wouldnt select just a segment file.  also, like i said, this runs

I'm not convinced.

If your getIndexDirectory() method is returning a string from a config
file (or something like that) and it includes a trailing seperator (in
addition to the seperator your code adds) then the index directory would
be created fine (if i remember right, extra seperates don't generate an
exception) but your string equality test would fail and you'd try to
delete the files in the directory you just created.

If your searcher has already opened some of the files, then (depending on
your OS) the delete code may not be able to delete them -- you're not
checking the return value from subFiles[j].delete() so you have no way of
knowing.  The segments file may be the only file getting deleted, because
it may be the only file your searcher doesn't have open at the moment the
delete code runs.  If i remember right IndexSearcher only opens the
segments file to get a list of all the individual segments, and then
immdeiately closes it, but keeps the rest of hte files open permenantly.

: fine on my laptop and g5.  and actually, this code was fine till
: recently on that box.  i modified a different method and updated the
: code to this server and now i have this problem.

what was the code that changed?



: :         String newPath = getIndexLocation() + File.separator +
: : System.currentTimeMillis();
: :
: :         IndexWriter writer = new IndexWriter(new File(newPath),
: : analyzer, true);
:
:       ...
:
: :         writer.optimize();
: :         writer.close();
: :
: :     SearchSO.setSearcher(newPath);
: :
: :     File[] subFiles;
: :     File[] subDirs = new File(getIndexLocation()).listFiles();
: :
: :     for (int i=0;i<subDirs.length;i++) {
: :             if (subDirs[i].isDirectory()) {
: :                     if (!newPath.equals(subDirs[i].getPath())) {
: :                             subFiles = subDirs[i].listFiles();
: :                             for (int j=0;j<subFiles.length;j++) {
: :                                     subFiles[j].delete();
: :                             }
: :                             subDirs[i].delete();
: :                     }
: :             }
: :     }
: :
: :
: :     }



-Hoss


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to