Exemplo n.º 1
0
        /// <summary>
        /// Returns a StoryCollection containing the stories that match for the given
        /// search term. The stories are returned in the correct order as given
        /// by the lucene results.
        /// </summary>
        /// <param name="results"></param>
        /// <returns></returns>
        internal static StoryCollection LoadStorySearchResults(IList <int> results)
        {
            if (results.Count == 0)
            {
                return(null);
            }

            StoryCollection stories = Story.GetStoriesByIds(results);

            //the stories are not returned in the hit order lucene found
            //the matches, the order is storyId asc. We need to correct
            //the order so the collection is correctly order as per the
            //hits result from lucene
            StoryCollection searchResults = new StoryCollection();

            foreach (int i in results)
            {
                Story s = (Story)stories.Find(i);
                searchResults.Add(s);
            }

            return(searchResults);
        }