示例#1
0
        public void Index(IEnumerable <Revision> entities)
        {
            var actions = entities.Select(e => new
            {
                deletes = _definition.GetIndex(e),
                adds    = _definition.Convert(e)
            });

            using (var indexWriter = GetIndexWriter(_config.IndexPath))
            {
                indexWriter.DeleteDocuments(actions.Select(a => a.deletes).ToArray());
                indexWriter.AddDocuments(actions.Select(a => a.adds).ToArray());
            }
        }
示例#2
0
        /// <summary>
        /// Indexes a single entity with the provided definition
        /// </summary>
        /// <typeparam name="TEntity">The type of entity to index</typeparam>
        /// <param name="entity">The entity to index</param>
        /// <param name="definition">The index definition</param>
        /// <returns>An index result with the outcome of the indexing operation</returns>
        public IndexResult IndexEntity <TEntity>(TEntity entity, IIndexDefinition <TEntity> definition) where TEntity : class
        {
            var result = new IndexResult();

            result.ExecutionTime = Time(() =>
            {
                this.GetWriter().UpdateDocument(definition.GetIndex(entity), definition.Convert(entity));
                result.Count++;
                result.Success = true;
            });

            return(result);
        }