You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Tim Patton <tp...@dealcatcher.com> on 2007/03/05 20:21:26 UTC

Missing .tii File

I'm not sure how, but in moving an index over from 2.0 to 2.1 and 
changing my own code one of the .tii files got deleted.  I still have 
the .tis file though, can I rebuild the missing file so I can open my 
index?  Luke won't open it now and I just want to make sure everything 
is ok before opening a writer and possibly doing some permanent damage.


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


Re: Missing .tii File

Posted by Tim Patton <tp...@dealcatcher.com>.

Tim Patton wrote:
> I'm not sure how, but in moving an index over from 2.0 to 2.1 and 
> changing my own code one of the .tii files got deleted.  I still have 
> the .tis file though, can I rebuild the missing file so I can open my 
> index?  Luke won't open it now and I just want to make sure everything 
> is ok before opening a writer and possibly doing some permanent damage.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
> 
> 
In the interest if helping out the next person with this problem, here 
is all my code to recover the missing .tii file when I still had the 
rest of the index.

Of course now I am also missing one .fN norm file so I will be trying to 
figure out how to recover that.  Looks like everything else is there, I 
have no idea how this happened.

package org.apache.lucene.index;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import org.apache.lucene.index.TermInfo;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;

public class TIIRecover
{
	public static void main(String[] args)
	{
		try
		{
			String segment="_aginr";
			Directory cfsDir=FSDirectory.getDirectory("c:/java/lib/lucene/recover");
			FieldInfos fieldInfos = new FieldInfos(cfsDir, segment + ".fnm");
			SegmentTermEnum origEnum = new 
SegmentTermEnum(cfsDir.openInput(segment + ".tis"), fieldInfos, false);

			List<Term> termList = new LinkedList<Term>();
			List<TermInfo> termInfoList = new LinkedList<TermInfo>();
			int count=0;
			while(origEnum.next())
			{
				Term term = origEnum.term();
				TermInfo ti = origEnum.termInfo();
				termList.add(term);
				termInfoList.add(ti);
				count++;
			}
			origEnum.close();
			System.out.println("Copied: "+count);
			count=0;

			TermInfosWriter termWriter = new TermInfosWriter(cfsDir, segment, 
fieldInfos, 128);//128 taken from TermInfosWriter.java
			Iterator<Term> termItr = termList.iterator();
			Iterator<TermInfo> termInfoItr = termInfoList.iterator();
			while(termItr.hasNext())
			{
				Term term =termItr.next();
				TermInfo ti = termInfoItr.next();
				termWriter.add(term, ti);
				count++;
			}
			termWriter.close();
			System.out.println("Saved: "+count);

		}
		catch(Throwable e)
		{
			System.err.println(e);
		}
	}
}


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