Ejemplo n.º 1
0
        /// <summary>
        /// Searches an index using the provided query and returns a strongly typed result object
        /// </summary>
        /// <typeparam name="T">The type of result object to return</typeparam>
        /// <param name="query">A Lucene query to use for the search</param>
        /// <param name="definition">A search definition used to transform the returned Lucene documents</param>
        /// <returns>A search result object containing both Lucene documents and typed objects based on the definition</returns>
        public SearchResult <T> SearchIndex <T>(Query query, IResultDefinition <T> definition)
        {
            var     searcher = this.GetSearcher();
            TopDocs hits     = null;

            hits = searcher.Search(query, 25000);
            var results = hits.ScoreDocs.Select(h => searcher.Doc(h.Doc));

            return(new SearchResult <T>(results, definition));
        }
Ejemplo n.º 2
0
 public SearchResult(IEnumerable <Document> documents, IResultDefinition <T> definition)
 {
     this.documents  = documents;
     this.definition = definition;
 }