Re: How to create a new index

2009-05-20 Thread KK
Thank you ag...@john. This is even better. I don't have to bother about the 3rd argument, right? I'll use the same one everytime for both registering a new core as well as adding docs to an existing one. Thanks, KK. On Wed, May 20, 2009 at 6:54 PM, John Byrne wrote: > Hi KK, > > You're welcome!

Re: How to create a new index

2009-05-20 Thread John Byrne
Hi KK, You're welcome! BTW, I had a quick look at the Javadoc for IndexWriter and noticed this constructor: public IndexWriter(Directory d, Analyzer a) "Constructs an IndexWriter for the index in d, first creating it if it does not already exist." I think that might solve your problem and

Re: How to create a new index

2009-05-20 Thread Erick Erickson
Unless something about your problem space *requires* that you reopen theindex, you're better off just opining it once, writing all your documents to it, then closing it. Although what you're doing will work, it's not very efficient. And the same thing is *especially* true of the searcher. There's

Re: How to create a new index

2009-05-20 Thread KK
Thanks a lot @John. That solved the problem and the other advice is really helpful. I'd have bumped over that otherwise. This clarifies my doubt, that everytime I've to create a new index just call the indexwriter with "true" thereby creating the directory, then start adding docs with "false" as th

Re: How to create a new index

2009-05-20 Thread John Byrne
I think the problem is that you are creating an new index every time you add a document: IndexWriter writer = new IndexWriter(trueIndexPath, new StandardAnalyzer(), true); The last argument, the boolean 'true' tells IndexWriter to overwrite any existing index in that directory. If you set that

Re: How to create a new index

2009-05-20 Thread KK
Thank you very much. I'm using the one mentioned by @Anshum ..but the problem is that after indexing some no of docs what I see is only the last one indexed which clearly indicates that the index is getting overwritten. I'm posing my simple indexer and searcher herewith. Actually I'm trying to craw

Re: How to create a new index

2009-05-20 Thread Anshum
Hi KK, Easier still, you could just open the indexwriter with the last (3rd) arguement as true, this way the indexwriter would create a new index as soon as you start indexing. Also, if you just leave the indexWriter without the 3rd arguement, it'd conditionally create a new directory i.e. only if

Re: How to create a new index

2009-05-20 Thread John Byrne
You can do this with pure Java. Create a file object with the path you want, check if it exists, and it not, create it: File newIndexDir = new File("/foo/bar") if(!newFileDir.exists()) { newDirFile.mkdirs(); } The 'mkdirs()' method creates any necessary parent directories. If you want t