コード例 #1
0
        public void Index(TEntity entity)
        {
            var document = IndexDefinition.Convert(entity);

            using (IndexWriter writer = new IndexWriter(MapDirectory, WriterConfiguration))
                writer.AddDocument(document);
        }
コード例 #2
0
ファイル: LuceneAction.cs プロジェクト: yxb1987/MrCMS
        public void Execute(IndexWriter writer)
        {
            Document document = IndexDefinition.Convert(Entity);
            Term     index    = IndexDefinition.GetIndex(Entity);

            if (document == null || index == null)
            {
                return;
            }
            switch (Operation)
            {
            case LuceneOperation.Insert:
                writer.AddDocument(document);
                break;

            case LuceneOperation.Update:
                writer.UpdateDocument(index, document);
                break;

            case LuceneOperation.Delete:
                writer.DeleteDocuments(index);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
コード例 #3
0
 public void Index(IEnumerable <TEntity> entities)
 {
     using (IndexWriter writer = new IndexWriter(MapDirectory, WriterConfiguration))
         foreach (var entity in entities)
         {
             writer.AddDocument(IndexDefinition.Convert(entity));
         }
 }