public FacetBasedBoostingScorer(FacetBasedBoostScorerBuilder parent, BoboSegmentReader reader, Scorer innerScorer) : base(innerScorer.Weight) { m_innerScorer = innerScorer; List <BoboDocScorer> list = new List <BoboDocScorer>(); foreach (var boostEntry in parent.m_boostMaps) { string facetName = boostEntry.Key; IFacetHandler handler = reader.GetFacetHandler(facetName); if (!(handler is IFacetScoreable)) { throw new ArgumentException(facetName + " does not implement IFacetScoreable"); } IFacetScoreable facetScoreable = (IFacetScoreable)handler; BoboDocScorer scorer = facetScoreable.GetDocScorer(reader, parent.m_scoringFunctionFactory, boostEntry.Value); if (scorer != null) { list.Add(scorer); } } m_facetScorers = list.ToArray(); m_docid = -1; }
public virtual Explanation Explain(AtomicReader indexReader, int docid, Explanation innerExplaination) { if (!(indexReader is BoboSegmentReader)) { throw new ArgumentException("IndexReader is not BoboSegmentReader"); } BoboSegmentReader reader = (BoboSegmentReader)indexReader; Explanation exp = new Explanation(); exp.Description = "FacetBasedBoost"; float boost = 1.0f; foreach (var boostEntry in m_boostMaps) { string facetName = boostEntry.Key; IFacetHandler handler = reader.GetFacetHandler(facetName); if (!(handler is IFacetScoreable)) { throw new ArgumentException(facetName + " does not implement IFacetScoreable"); } IFacetScoreable facetScoreable = (IFacetScoreable)handler; BoboDocScorer scorer = facetScoreable.GetDocScorer(reader, m_scoringFunctionFactory, boostEntry.Value); float facetBoost = scorer.Score(docid); Explanation facetExp = new Explanation(); facetExp.Description = facetName; facetExp.Value = facetBoost; facetExp.AddDetail(scorer.Explain(docid)); boost *= facetBoost; exp.AddDetail(facetExp); } exp.Value = boost; exp.AddDetail(innerExplaination); return(exp); }