add_document(intval($docid)); } $qp = new XapianQueryParser(); $stemmer = new XapianStem("english"); $qp->set_stemmer($stemmer); $qp->set_database($database); $qp->set_stemming_strategy(XapianQueryParser::STEM_SOME); $query = $qp->parse_query($query_string); print "Parsed query is: {$query->get_description()}\n"; // Find the top 10 results for the query. $enquire->set_query($query); $matches = $enquire->get_mset(0, 10, $rset); // Display the results. print "{$matches->get_matches_estimated()} results found:\n"; $i = $matches->begin(); while (!$i->equals($matches->end())) { $n = $i->get_rank() + 1; $data = $i->get_document()->get_data(); print "$n: {$i->get_percent()}% docid={$i->get_docid()} [$data]\n\n"; $i->next(); } // If no relevant docids were given, invent an RSet containing the top 5 // matches (or all the matches if there are less than 5). if ($rset->is_empty()) { $c = 5; $i = $matches->begin(); while ($c-- && !$i->equals($matches->end())) { $rset->add_document($i->get_docid()); $i->next(); } } // Generate an ESet containing terms that the user might want to add to // the query. $eset = $enquire->get_eset(10, $rset); // List the terms. for ($t = $eset->begin(); !$t->equals($eset->end()); $t->next()) { print "{$t->get_term()}: weight = {$t->get_weight()}\n"; } } catch (Exception $e) { print $e->getMessage() . "\n"; exit(1); } ?>