Reading an existing index

Jul 17, 2012 at 9:09 AM

Hello,

is it possible to use this library to read an existing Lucene/Lucene.NET index without having to connect to a database?

Developer
Jul 17, 2012 at 6:41 PM

The library doesn't use a database as a mean of storage, it uses Lucene.NET itself. So, I don't see any reason why you wouldn't be able to read an existing Lucene.NET index. As for the Lucene index, I'm not sure - it depends on the differences (if any) between the index implementations of Lucene and Lucene.NET

Jul 17, 2012 at 9:55 PM
Yes, my question was exactly how do I do that? I can't figure out by
the documentation.

2012/7/17, stemarie <notifications@codeplex.com>:
> From: stemarie
>
> The library doesn't use a database as a mean of storage, it uses Lucene.NET
> itself. So, I don't see any reason why you wouldn't be able to read an
> existing Lucene.NET index. As for the Lucene index, I'm not sure - it
> depends on the differences (if any) between the index implementations of
> Lucene and Lucene.NET
>
>

--
Inviato dal mio dispositivo mobile
Jul 18, 2012 at 11:15 AM

Here's what I'm doing:

var i = new Index<MyDoc>("some folder containing index files");
	
var results = i.Where(d => d.Message.StartsWith("Exception")).ToList();

After executing the second line the index directory is wiped out.

Developer
Jul 18, 2012 at 6:36 PM

Ok, I understand

When you use LinqToLucene the structure of the Lucene.NET index, while it is the actual index will be used to store objects in a very specific format. It is possible to use an existing index but you should probably do a data/copy to a new index.

Regretfully, the project isn't mature enough for this type of seamless transition.

Jul 18, 2012 at 8:31 PM

Simone_b

I hit the exact same problem this PM. Seems that a write lock is held open (you'll see a write.lock in your index directory) this isn't deleted after you've created your index. When you open the index up again using new Index<yourDocType>(path) the CreateModifiers call in the IndexContext has "issues". It sees the lock and opts to create a new IndexWriter - re-creating your index. Therefore deleting the entire index. It fails with a timeout on being able to obtain a write lock.

When you've created your index make sure you call Dispose on the Index instance. This gets rid of all the held locks and the write.lock file. When you open the index for querying make sure you call Dispose when you're done - opening the Index automatically creates a new write lock

You can test this by deleting the write.lock file and then trying to re-open the index.

Jul 18, 2012 at 10:08 PM

Thanks Andrew, that's correct. Unfortunately stemarie is correct as well and existing Lucene.NET indexes created by other means cannot be queried using this project, which is unfortunate.

Jun 10, 2013 at 5:11 PM
Edited Jun 10, 2013 at 5:11 PM
If you dispose and re create the index when you want to query it takes a few precious seconds each time. this is problematic. Isn't there a way to work against the files instead of the Ram, much like Lucene.Net?