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

            using (IndexWriter writer = new IndexWriter(MapDirectory, WriterConfiguration))
                writer.AddDocument(document);
        }
示例#2
0
        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));
         }
 }