/// <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()); }
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; } }
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; } }
/// <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()); }
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)); } }
private static IEnumerable<Guid> _mapLuceneToDataList(IEnumerable<ScoreDoc> hits, Searchable searcher) { return hits.Select(hit => _mapLuceneDocumentToData(searcher.Doc(hit.Doc))).ToList(); }
private static IEnumerable <Guid> _mapLuceneToDataList(IEnumerable <ScoreDoc> hits, Searchable searcher) { return(hits.Select(hit => _mapLuceneDocumentToData(searcher.Doc(hit.Doc))).ToList()); }
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 static IEnumerable <SearchResult> MapLuceneToDataList(IEnumerable <ScoreDoc> hits, Searchable searcher) { return(hits.Select(hit => ToSearchResult(searcher.Doc(hit.Doc))).ToList()); }