Ejemplo n.º 1
0
        /// <summary>
        /// Searches items and returns them in order of relevance.
        /// </summary>
        /// <param name="items">The items.</param>
        /// <param name="searchTerm">The search term.</param>
        /// <returns>IEnumerable{BaseItem}.</returns>
        /// <exception cref="System.ArgumentNullException">searchTerm</exception>
        public IEnumerable <BaseItem> Search(IEnumerable <BaseItem> items, string searchTerm)
        {
            if (string.IsNullOrEmpty(searchTerm))
            {
                throw new ArgumentNullException("searchTerm");
            }

            var hits = LuceneSearch.Search(searchTerm, items.Count());

            //return hits;
            return(hits.Where(searchHit => items.Any(p => p.Id == searchHit.Id)));
        }
Ejemplo n.º 2
0
        //public void LibraryChanged(object source, ChildrenChangedEventArgs changeInformation)
        //{
        //    Task.Run(() =>
        //    {
        //        if (changeInformation.ItemsAdded.Count + changeInformation.ItemsUpdated.Count > 0)
        //        {
        //            LuceneSearch.AddUpdateLuceneIndex(changeInformation.ItemsAdded.Concat(changeInformation.ItemsUpdated));
        //        }

        //        if (changeInformation.ItemsRemoved.Count > 0)
        //        {
        //            LuceneSearch.RemoveFromLuceneIndex(changeInformation.ItemsRemoved);
        //        }
        //    });
        //}

        public void AddItemsToIndex(IEnumerable <BaseItem> items)
        {
            LuceneSearch.AddUpdateLuceneIndex(items);
        }