我正在使用Sitecore Solr搜索使用關鍵字字符串進行搜索,有沒有辦法知道每個返回結果項目的匹配數量?Sitecore Solr搜索結果項匹配計數
以下是我使用的代碼:
using (var context = Index.CreateSearchContext())
{
List<Item> ResultList = new List<Item>();
var contentPredicate = PredicateBuilder.True<customSearchResultItem>();
contentPredicate = contentPredicate.And(p => p.Content.Contains(SearchKey));
contentPredicate = contentPredicate.And(p => p.Name != "__Standard Values");
var languagePredicate = PredicateBuilder.True<customSearchResultItem>();
languagePredicate = languagePredicate.And(p => p.Language == Context.Language.Name);
var CombinPredicates = PredicateBuilder.True<customSearchResultItem>();
CombinPredicates = CombinPredicates.And(languagePredicate);
CombinPredicates = CombinPredicates.And(contentPredicate);
// execute the search
IQueryable<customSearchResultItem> query = context.GetQueryable<customSearchResultItem>().Where(CombinPredicates);
var hits = query.GetResults().Hits;
}
我以前嘗試這樣做,得分值將是所有的結果項相同的,如果關鍵字謂詞匹配,我需要像遞增在當前項目上找到的每個比賽的得分值? –