How to index part of the table using LINQ to Lucene

Jul 25, 2009 at 11:01 PM

Hi,

I am now using the following code to index the database.

var dbi = new DatabaseIndexSet<DataContext>(
                @"C:\Index",
                new DataContext());

dbi.Write();

My problem is, the above code will index all the tables in the DataContext, but sometimes I only need to index part of the contents of one table. Anyone here knows how to do this?

Thank you!

Coordinator
Jul 27, 2009 at 8:52 AM

DbIndexSet derives form IndexSet which is just a collection of Indexes. So you can access the Index object you want from DbIndexSet

 

var myidx = dbi.Get<MyDbItem>();

Then you can just add an IEnumerble<MyDbItem> into the index as such

var items = from i in dbContext.MyDbItem where i.Blah>12 select i;

myidx.Add(items);

 

Too easy :)