private RankableSearchResultItem AddNewItem(SearchResultRankCalculator rankCalculator, double lucene) { return(rankCalculator.Add(_id++, SearchResultType.Page, "", lucene, DateTime.MinValue, null, 0)); }
private RankableSearchResultItem NewItemFromSet(double lucene, double?rating, int ratingCount, double ratingMidpoint) { var c = new SearchResultRankCalculator(0, 0, 0, ratingMidpoint, 0, 0); return(c.Add(_id++, SearchResultType.Page, "", lucene, DateTime.MinValue, rating, ratingCount)); }
private RankableSearchResultItem AddNewItem(SearchResultRankCalculator rankCalculator, double lucene, double?rating, int ratingCount) { return(rankCalculator.Add(_id++, SearchResultType.Page, "", lucene, DateTime.MinValue, rating, ratingCount)); }
private RankableSearchResultItem NewItemFromSet(double lucene, double? rating, int ratingCount, double ratingMidpoint) { var c = new SearchResultRankCalculator(0, 0, 0, ratingMidpoint, 0, 0); return c.Add(_id++, SearchResultType.Page, "", lucene, DateTime.MinValue, rating, ratingCount); }
private RankableSearchResultItem AddNewItem(SearchResultRankCalculator rankCalculator, double lucene) { return rankCalculator.Add(_id++, SearchResultType.Page, "", lucene, DateTime.MinValue, null, 0); }
private RankableSearchResultItem AddNewItem(SearchResultRankCalculator rankCalculator, double lucene, double? rating, int ratingCount) { return rankCalculator.Add(_id++, SearchResultType.Page, "", lucene, DateTime.MinValue, rating, ratingCount); }
public SearchResult CacheQuery(XDoc searchDoc, SearchQuery query, TrackingInfo trackingInfo) { var key = GetQueryKey(query.LuceneQuery); var documents = searchDoc["document"]; if (trackingInfo != null) { if (!trackingInfo.QueryId.HasValue) { // new tracked query _log.Debug("creating new tracked query"); trackingInfo.QueryId = _session.SearchAnalytics_LogQuery(query, searchDoc["parsedQuery"].AsText, _user.ID, (uint)documents.ListLength, trackingInfo.PreviousQueryId); } else { _log.Debug("recreating tracked query that fell out of cache"); } } else { _log.Debug("untracked query"); } var results = new SearchResultRankCalculator( _settings.GetValue("search/rating-promote-boost", RATING_PROMOTE_BOOST), _settings.GetValue("search/rating-demote-boost", RATING_DEMOTE_BOOST), _settings.GetValue("search/rating-count-threshold", RATING_COUNT_THRESHOLD), _settings.GetValue("search/rating-rank-midpoint", RATING_RANK_MIDPOINT), _settings.GetValue("search/search-popularity-boost", SEARCH_POPULARITY_BOOST), _settings.GetValue("search/search-popularity-threshold", SEARCH_POPULARITY_THRESHOLD) ); _log.Debug("building rank calculator set"); foreach (var entry in documents) { try { SearchResultType type; var typeId = entry["id.file"].AsUInt; if (typeId.HasValue) { type = SearchResultType.File; } else { typeId = entry["id.comment"].AsUInt; if (typeId.HasValue) { type = SearchResultType.Comment; } else { typeId = entry["id.user"].AsUInt; if (typeId.HasValue) { type = SearchResultType.User; } else { typeId = entry["id.page"].AsUInt; if (typeId.HasValue) { type = SearchResultType.Page; } else { _log.WarnFormat("dropping unsupported result item {0}", entry["type"]); continue; } } } } results.Add( typeId.Value, type, entry["title"].AsText, entry["score"].AsDouble ?? 0, DbUtils.ToDateTime(entry["date.edited"].AsText), entry["rating.score"].AsDouble, entry["rating.count"].AsInt ?? 0 ); } catch (Exception e) { // skip any item we cannot process, but log debug to see if there is a bad value pattern that's not related to stale index data _log.DebugFormat("unable to parse lucene result value because of '{0} ({1})' from: {2}", e.GetType(), e.Message, entry.ToString()); } } if (IsAdaptiveSearchEnabled) { var popularity = _session.SearchAnalytics_GetPopularityRanking(query.GetOrderedTermsHash()); results.ComputeRank(popularity); } else { _log.Debug("ranking disabled in non-commercial version"); } var searchResults = new SearchResult(searchDoc["parsedQuery"].AsText, results.ToArray()); _log.DebugFormat("putting results into cache with key: {0}", key); _cache.Set(key, searchResults, TimeSpan.FromSeconds(_settings.GetValue("search/set-cache-time", 120d))); return(searchResults); }