public DownloadsScoreProvider(IndexReader reader, IReadOnlyDictionary <string, int[]> idMapping, Downloads downloads, RankingResult ranking, QueryBoostingContext context, double baseBoost) : base(reader) { _idMapping = idMapping; _downloads = downloads; _baseBoost = baseBoost; _ranking = ranking; _context = context; // We need the reader name: Lucene *may* have multiple segments (which are smaller indices) // and RankingsHandler provides us with the per-segment document numbers. // // If no segments are present (small index) we use an empty string, which is what // Lucene also uses internally. var segmentReader = reader as SegmentReader; _readerName = segmentReader != null ? segmentReader.SegmentName : string.Empty; }
public DownloadsScoreProvider(IndexReader reader, IReadOnlyDictionary<string, int[]> idMapping, Downloads downloads, RankingResult ranking, QueryBoostingContext context, double baseBoost) : base(reader) { _idMapping = idMapping; _downloads = downloads; _baseBoost = baseBoost; _ranking = ranking; _context = context; // We need the reader name: Lucene *may* have multiple segments (which are smaller indices) // and RankingsHandler provides us with the per-segment document numbers. // // If no segments are present (small index) we use an empty string, which is what // Lucene also uses internally. var segmentReader = reader as SegmentReader; _readerName = segmentReader != null ? segmentReader.SegmentName : string.Empty; }
public static float DownloadScore(long totalDownloads, QueryBoostingContext context) { if (!context.BoostByDownloads) { return(1.0f); } // Logarithmic scale for downloads counts, high downloads get slightly better result up to ~2 // Packages below the threshold return 1.0 long adjustedCount = Math.Max(1, totalDownloads - context.Threshold); double scoreAdjuster = Math.Log10(adjustedCount) / context.Factor + 1; return((float)scoreAdjuster); }
public static float DownloadScore(long totalDownloads, QueryBoostingContext context) { if (!context.BoostByDownloads) { return 1.0f; } // Logarithmic scale for downloads counts, high downloads get slightly better result up to ~2 // Packages below the threshold return 1.0 long adjustedCount = Math.Max(1, totalDownloads - context.Threshold); double scoreAdjuster = Math.Log10(adjustedCount) / context.Factor + 1; return (float)scoreAdjuster; }
private void ReloadAuxiliaryDataIfExpired() { if (LastAuxiliaryDataLoadTime == null || LastAuxiliaryDataLoadTime < DateTime.UtcNow - _auxiliaryDataRefreshRate) { IndexingUtils.Load(AuxiliaryFiles.Owners, _loader, _logger, _owners); IndexingUtils.Load(AuxiliaryFiles.CuratedFeeds, _loader, _logger, _curatedFeeds); _downloads.Load(AuxiliaryFiles.DownloadsV1, _loader, _logger); _rankings = DownloadRankings.Load(AuxiliaryFiles.RankingsV1, _loader, _logger); _queryBoostingContext = QueryBoostingContext.Load(AuxiliaryFiles.SearchSettingsV1, _loader, _logger); _verifiedPackages = VerifiedPackages.Load(AuxiliaryFiles.VerifiedPackages, _loader, _logger); LastAuxiliaryDataLoadTime = DateTime.UtcNow; AuxiliaryFiles.UpdateLastModifiedTime(); } }
public DownloadsBoostedQuery(Query query, IReadOnlyDictionary <string, int[]> docIdMapping, Downloads downloads, RankingResult ranking, QueryBoostingContext context, double baseBoost = BaseBoostConstant) : base(query) { _docIdMapping = docIdMapping; _downloads = downloads; _baseBoost = baseBoost; _ranking = ranking; _context = context; Query = query; }
public DownloadsBoostedQuery(Query query, IReadOnlyDictionary<string, int[]> docIdMapping, Downloads downloads, RankingResult ranking, QueryBoostingContext context, double baseBoost = BaseBoostConstant) : base(query) { _docIdMapping = docIdMapping; _downloads = downloads; _baseBoost = baseBoost; _ranking = ranking; _context = context; Query = query; }
private static Query MakeAutoCompleteQuery(string q, IReadOnlyDictionary <string, int[]> docIdMapping, Downloads downloads, RankingResult rankings, QueryBoostingContext context) { var query = NuGetQuery.MakeAutoCompleteQuery(q); var boostedQuery = new DownloadsBoostedQuery(query, docIdMapping, downloads, rankings, context, 2.0); return(boostedQuery); }
public NuGetIndexSearcher( NuGetSearcherManager manager, IndexReader reader, IDictionary <string, string> commitUserData, IDictionary <string, Filter> curatedFeeds, Dictionary <LatestListedMask, Filter> latest, IReadOnlyDictionary <string, int[]> docIdMapping, Downloads downloads, VersionResult[] versions, RankingResult rankings, QueryBoostingContext context, OpenBitSet latestBitSet, OpenBitSet latestStableBitSet, OpenBitSet latestSemVer2BitSet, OpenBitSet latestStableSemVer2BitSet, OwnersResult owners, HashSet <string> verifiedPackages) : base(reader) { Manager = manager; CommitUserData = commitUserData; _curatedFeeds = new Dictionary <string, Filter>(curatedFeeds.Count); foreach (var curatedFeedsFilter in curatedFeeds) { _curatedFeeds.Add(curatedFeedsFilter.Key, new CachingWrapperFilter(curatedFeedsFilter.Value)); } _latest = latest; DocIdMapping = docIdMapping; Downloads = downloads; Versions = versions; Rankings = rankings; LatestBitSet = latestBitSet; LatestStableBitSet = latestStableBitSet; LatestSemVer2BitSet = latestSemVer2BitSet; LatestStableSemVer2BitSet = latestStableSemVer2BitSet; Owners = owners; VerifiedPackages = verifiedPackages; QueryBoostingContext = context; LastReopen = DateTime.UtcNow; }
public NuGetIndexSearcher( NuGetSearcherManager manager, IndexReader reader, IDictionary<string, string> commitUserData, IDictionary<string, Filter> curatedFeeds, Filter[][] latest, IReadOnlyDictionary<string, int[]> docIdMapping, Downloads downloads, VersionResult[] versions, RankingResult rankings, QueryBoostingContext context, OpenBitSet latestBitSet, OpenBitSet latestStableBitSet, OwnersResult owners) : base(reader) { Manager = manager; CommitUserData = commitUserData; _curatedFeeds = new Dictionary<string, Filter>(curatedFeeds.Count); foreach (var curatedFeedsFilter in curatedFeeds) { _curatedFeeds.Add(curatedFeedsFilter.Key, new CachingWrapperFilter(curatedFeedsFilter.Value)); } _latest = latest; DocIdMapping = docIdMapping; Downloads = downloads; Versions = versions; Rankings = rankings; LatestBitSet = latestBitSet; LatestStableBitSet = latestStableBitSet; Owners = owners; QueryBoostingContext = context; LastReopen = DateTime.UtcNow; }
private static Query MakeAutoCompleteQuery(string q, IReadOnlyDictionary<string, int[]> docIdMapping, Downloads downloads, RankingResult rankings, QueryBoostingContext context) { var query = NuGetQuery.MakeAutoCompleteQuery(q); var boostedQuery = new DownloadsBoostedQuery(query, docIdMapping, downloads, rankings, context, 2.0); return boostedQuery; }