Skip to content

Instantly share code, notes, and snippets.

@ianbarber
Created April 19, 2011 21:09
Show Gist options
  • Save ianbarber/929669 to your computer and use it in GitHub Desktop.
Save ianbarber/929669 to your computer and use it in GitHub Desktop.
Xapian More Like This
<?php
$posting = $database->postlist_begin( $search_id );
$enquire = new XapianEnquire( $database );
$rset = new XapianRset();
$rset->add_document( $posting->get_docid() );
$eset = $enquire->get_eset(20, $rset);
$i = $eset->begin();
$terms = array();
while ( !$i->equals($eset->end()) ) {
$terms[] = $i->get_term();
$i->next();
}
$query = new XapianQuery( XapianQuery::OP_OR, $terms );
$enquire->set_query( $query );
$matches = $enquire->get_mset( 0, $max_recommended+1 );
$ids = array();
$i = $matches->begin();
while ( !$i->equals($matches->end()) ) {
$n = $i->get_rank() + 1;
if( $i->get_document()->get_value( $field_id ) != $post->id ) {
$ids[] = $i->get_document()->get_value( $field_id );
}
$i->next();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment