Explanation* explain(IndexReader* reader, int32_t doc) { ConstantScorer* cs = (ConstantScorer*)scorer(reader); bool exists = cs->bits->get(doc); _CLDELETE(cs); ComplexExplanation* result = _CLNEW ComplexExplanation(); if (exists) { StringBuffer buf(100); buf.append(_T("ConstantScoreQuery(")); TCHAR* tmp = parentQuery->filter->toString(); buf.append(tmp); _CLDELETE_LCARRAY(tmp); buf.append(_T("), product of:")); result->setDescription(buf.getBuffer()); result->setValue(queryWeight); result->setMatch(true); result->addDetail(_CLNEW Explanation(parentQuery->getBoost(), _T("boost"))); result->addDetail(_CLNEW Explanation(queryNorm, _T("queryNorm"))); } else { StringBuffer buf(100); buf.append(_T("ConstantScoreQuery(")); TCHAR* tmp = parentQuery->filter->toString(); buf.append(tmp); _CLLDELETE(tmp); buf.append(_T(") doesn't match id ")); buf.appendInt(doc); result->setDescription(buf.getBuffer()); result->setValue(0); result->setMatch(true); } _CLLDELETE(cs); return result; }
Explanation* Explanation::clone() const{ return _CLNEW Explanation(*this); }