Exemplo n.º 1
0
 /// <summary>
 /// Maps the search to data list.
 /// </summary>
 /// <param name="searcher">The searcher.</param>
 /// <param name="hits">The hits.</param>
 /// <param name="userAccessList">The user access list.</param>
 /// <returns>
 /// Returns the search list
 /// </returns>
 private static List <SearchMessage> MapSearchToDataList(
     Searchable searcher,
     IEnumerable <ScoreDoc> hits,
     List <vaccess> userAccessList)
 {
     return(hits.Select(hit => MapSearchDocumentToData(searcher.Doc(hit.Doc), userAccessList))
            .GroupBy(x => x.Topic).Select(y => y.FirstOrDefault()).ToList());
 }
Exemplo n.º 2
0
 public IntersectionCollector(Searchable indexSearcher, IEnumerable <ScoreDoc> scoreDocs, IState state)
 {
     foreach (var scoreDoc in scoreDocs)
     {
         var document       = indexSearcher.Doc(scoreDoc.Doc, state);
         var subQueryResult = new SubQueryResult
         {
             LuceneId   = scoreDoc.Doc,
             RavenDocId = document.Get(Constants.Documents.Indexing.Fields.DocumentIdFieldName, state) ?? document.Get(Constants.Documents.Indexing.Fields.ReduceKeyHashFieldName, state),
             Score      = float.IsNaN(scoreDoc.Score) ? 0.0f : scoreDoc.Score,
             Count      = 1
         };
         _results[subQueryResult.RavenDocId] = subQueryResult;
     }
 }
Exemplo n.º 3
0
 public IntersectionCollector(Searchable indexSearcher, IEnumerable<ScoreDoc> scoreDocs)
 {
     foreach (var scoreDoc in scoreDocs)
     {
         var document = indexSearcher.Doc(scoreDoc.Doc);
         var subQueryResult = new SubQueryResult
         {
             LuceneId = scoreDoc.Doc,
             RavenDocId = document.Get(Constants.DocumentIdFieldName) ?? document.Get(Constants.ReduceKeyFieldName),
             Score = float.IsNaN(scoreDoc.Score) ? 0.0f : scoreDoc.Score,
             Count = 1
         };
         results[subQueryResult.RavenDocId] = subQueryResult;
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Maps the search to data list.
        /// </summary>
        /// <param name="highlighter">The highlighter.</param>
        /// <param name="analyzer">The analyzer.</param>
        /// <param name="searcher">The searcher.</param>
        /// <param name="hits">The hits.</param>
        /// <param name="pageIndex">Index of the page.</param>
        /// <param name="pageSize">Size of the page.</param>
        /// <param name="userAccessList">The user access list.</param>
        /// <returns>
        /// Returns the search list
        /// </returns>
        private List <SearchMessage> MapSearchToDataList(
            Highlighter highlighter,
            Analyzer analyzer,
            Searchable searcher,
            IEnumerable <ScoreDoc> hits,
            int pageIndex,
            int pageSize,
            List <vaccess> userAccessList)
        {
            var skip = pageSize * (pageIndex - 1);

            return(hits.Select(
                       hit => this.MapSearchDocumentToData(highlighter, analyzer, searcher.Doc(hit.Doc), userAccessList))
                   .OrderByDescending(s => s.MessageId).Skip(skip).Take(pageSize).ToList());
        }
Exemplo n.º 5
0
        private IList <int> BuildSearchResult(TopDocs topDocs, Searchable indexSearcher)
        {
            var total  = topDocs.TotalHits;
            var result = new List <int>();

            for (int i = 0; i < total; i++)
            {
                if (i == this.configuracoesDaAplicacao.ResultadoMaximoConsulta)
                {
                    break;
                }

                var docIndex = topDocs.ScoreDocs[i].Doc;
                var doc      = indexSearcher.Doc(docIndex);
                result.Add(doc.Get("documentoId").ToInt());
            }

            return(result);
        }
        private IEnumerable <T> EnumerateHits <T>(TopDocs hits, QueryExecutionContext executionContext, Searchable searcher, IRetrievedDocumentTracker <TDocument> tracker, ItemHolder itemHolder, int skipResults, Func <TDocument, T> projector)
        {
            for (var i = skipResults; i < hits.ScoreDocs.Length; i++)
            {
                executionContext.CurrentHit      = i;
                executionContext.CurrentScoreDoc = hits.ScoreDocs[i];

                var docNum   = hits.ScoreDocs[i].Doc;
                var document = searcher.Doc(docNum);

                if (tracker == null)
                {
                    itemHolder.Current = ConvertDocument(document, executionContext);
                    yield return(projector(itemHolder.Current));

                    continue;
                }

                var key = GetDocumentKey(document, executionContext);

                if (tracker.IsMarkedForDeletion(key))
                {
                    continue;
                }

                TDocument item;
                if (!tracker.TryGetTrackedDocument(key, out item))
                {
                    item = ConvertDocument(document, executionContext);
                    tracker.TrackDocument(key, item, document);
                }

                itemHolder.Current = item;
                yield return(projector(itemHolder.Current));
            }
        }
Exemplo n.º 7
0
 private static IEnumerable<Guid> _mapLuceneToDataList(IEnumerable<ScoreDoc> hits, Searchable searcher)
 {
     return hits.Select(hit => _mapLuceneDocumentToData(searcher.Doc(hit.Doc))).ToList();
 }
Exemplo n.º 8
0
 private static IEnumerable <Guid> _mapLuceneToDataList(IEnumerable <ScoreDoc> hits, Searchable searcher)
 {
     return(hits.Select(hit => _mapLuceneDocumentToData(searcher.Doc(hit.Doc))).ToList());
 }
Exemplo n.º 9
0
        private IList<int> BuildSearchResult(TopDocs topDocs, Searchable indexSearcher)
        {
            var total = topDocs.TotalHits;
            var result = new List<int>();

            for (int i = 0; i < total; i++)
            {
                if (i == this.configuracoesDaAplicacao.ResultadoMaximoConsulta)
                {
                    break;
                }

                var docIndex = topDocs.ScoreDocs[i].Doc;
                var doc = indexSearcher.Doc(docIndex);
                result.Add(doc.Get("documentoId").ToInt());
            }

            return result;
        }
Exemplo n.º 10
0
 private static IEnumerable <SearchResult> MapLuceneToDataList(IEnumerable <ScoreDoc> hits, Searchable searcher)
 {
     return(hits.Select(hit => ToSearchResult(searcher.Doc(hit.Doc))).ToList());
 }