【发布时间】:2014-08-01 06:38:37
【问题描述】:
我在我的电子商务应用程序(Asp.Net Mvc3,Sql server 2008)中实现 Lucene.Net,它有巨大的数据库。因此,索引产品的操作变得非常繁重。虽然一次索引它对我来说是可以的。
现在,当我更新、创建、删除特定产品的任何产品索引时,都应该相应地更新。
我还通过 Excel 表格实现了产品的批量更新。因此,通过此操作插入、更新或删除了更多的产品。我应该选择什么方法来重新索引我的产品?
由于大多数产品保持不变,重新索引所有产品并增加服务器负载可能不是一个好主意。
我的产品索引代码是
foreach (var p in products)
{
//Create the Document object
// object temp = p;
Document doc = new Document();
var properties = p.GetType().GetProperties();
foreach (PropertyInfo propertyInfo in properties)
{
//Populate the document with the column name and value from our query
var value = propertyInfo.GetValue(p, null);
doc.Add(new Field(propertyInfo.Name, value == null ? "" : value.ToString(), Field.Store.YES, Field.Index.ANALYZED));
}
// Write the Document to the catalog
indexWriter.AddDocument(doc);
}
任何人都知道解决方法。有没有办法不使用 foreach 或类似的东西来索引文档。
【问题讨论】:
标签: c# asp.net-mvc-3 indexing lucene.net