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

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