Xapian索引-文档检索过程分析之匹配百分比
Xapian::Query term_one = Xapian::Query("T世界"); Xapian::Query term_two = Xapian::Query("T比赛"); Xapian::Query query = Xapian::Query(Xapian::Query::OP_OR, term_one, term_two); // query组装 std::cout << "query=" << query.get_description() << std::endl; Xapian::Enquire enquire(db); enquire.set_query(query); Xapian::MSet result = enquire.get_mset(, 10); // 执行检索,获取结果 std::cout << "find results count=" << result.get_matches_estimated() << std::endl; for (auto it = result.begin(); it != result.end(); ++it) { Xapian::Document doc = it.get_document(); std::string data = doc.get_data(); double doc_score_weight = it.get_weight(); /// 匹配百分比 int doc_score_percent = it.get_percent(); std::cout << "doc=" << data << ",weight=" << doc_score_weight << ",percent=" << doc_score_percent << std::endl; }
相关文章