Exemplo n.º 1
0
 public LuceneIndexable(T target,
                        Tkey tkey, LuceneIndexBehavior <T> indexBehavior)
 {
     this.target        = target;
     id                 = tkey;
     this.indexBehavior = indexBehavior;
 }
Exemplo n.º 2
0
        /// <summary>
        /// 创建索引
        /// </summary>
        public void CreateIndex <T, TKey>(T[] indexObjects, Expression <Func <T, TKey> > keySelector, LuceneIndexBehavior <T> behavior = null)
        {
            if (LuceneIndexer == null)
            {
                return;
            }

            var index      = new List <ILuceneIndexable>();
            var properties = typeof(T).GetProperties();

            foreach (var obj in indexObjects)
            {
                index.Add(new LuceneIndexable <T, TKey>(obj, keySelector.Compile()(obj), behavior));
            }

            if (index.Any())
            {
                LuceneIndexer.CreateIndex(index);
            }
        }