diff --git a/MediaBrowser.Server.Implementations/Library/LuceneSearchEngine.cs b/MediaBrowser.Server.Implementations/Library/LuceneSearchEngine.cs index a27244a57..ed085c777 100644 --- a/MediaBrowser.Server.Implementations/Library/LuceneSearchEngine.cs +++ b/MediaBrowser.Server.Implementations/Library/LuceneSearchEngine.cs @@ -70,7 +70,10 @@ namespace MediaBrowser.Server.Implementations.Library throw new ArgumentNullException("searchTerm"); } - return LuceneSearch.Search(searchTerm); + var hits = LuceneSearch.Search(searchTerm, items.Count()); + + //return hits; + return hits.Where(searchHit => items.Any(p => p.Id == searchHit.Id)); } public void Dispose() @@ -229,7 +232,7 @@ namespace MediaBrowser.Server.Implementations.Library writer.Flush(true, true, true); } - public static IEnumerable Search(string searchQuery) + public static IEnumerable Search(string searchQuery, int maxHits) { var results = new List(); @@ -255,7 +258,7 @@ namespace MediaBrowser.Server.Implementations.Library logger.Debug("Querying Lucene with query: " + finalQuery.ToString()); long start = DateTime.Now.Ticks; - var searchResult = searcher.Search(finalQuery, 20); + var searchResult = searcher.Search(finalQuery, maxHits); foreach (var searchHit in searchResult.ScoreDocs) { Document hit = searcher.Doc(searchHit.Doc);