views:

202

answers:

2

I've an asp.net web application which uses Lucene API for search. Here is the problem scenario:

Events:

  1. User invokes a Lucene search query thru the web application.
  2. There is another windows service running which just copies the search index folder to another folder.

When event 2 occurs after event 1 has occurred, I am getting error below while copying the index:

The process cannot access the file 'C:\Indexes\segments.gen'
because it is being used by another process.

What am i missing here?

FYI, am using System.IO.File.Copy with overwrite set to true to copy index files.

+1  A: 

The problem is because the first event locks Lucine files, You can create 2 copies of the same index, and synchronize you processes to not prevent each other

ArsenMkrt
thanks for ur comments...could you please elaborate ur explanation?
Jimmy
A: 

I described how I used Lucene.NET in an ASP.NET application here:
http://ifdefined.com/blog/post/Full-Text-Search-in-ASPNET-using-LuceneNET.aspx

My code might not be right for a high volume website, but for low volume, it does seem to solve he problem you are having.

Corey Trager