// get the result of search $nres = &$node->search($cond, 0); if ($nres) { // for each document in the result for ($i = 0; $i < $nres->doc_num(); $i++) { // get a result document object $rdoc = &$nres->get_doc($i); // display attributes if (($value = $rdoc->attr('@uri')) !== null) { fputs(STDOUT, sprintf("URI: %s\n", $value)); } if (($value = $rdoc->attr('@title')) !== null) { fputs(STDOUT, sprintf("Title: %s\n", $value)); } // display the snippet text fputs(STDOUT, sprintf("%s", $rdoc->snippet())); } if ($i == 0) { fputs(STDERR, "not found.\n"); } // debug output //var_dump($i, $j, $nres->doc_num()); } else { fputs(STDERR, sprintf("error: %d\n", $node->status())); $stack = &EstraierPure_Utility::errorstack(); if ($stack->hasErrors()) { fputs(STDERR, print_r($stack->getErrors(), true)); } } ?>
/** * Push the error to the error stack. * * @param object &$error PEAR_Error An error object * @return void * @access public * @static */ function push_error(&$error) { $stack =& EstraierPure_Utility::errorstack(); $stack->push($error->getCode(), 'error', array('object' => $error), $error->getMessage(), false, $error->getBacktrace()); }
//define('ESTRAIERPURE_USE_HTTP_STREAM', 1); error_reporting(E_ALL & ~E_STRICT); require_once 'estraierpure.php5'; // create and configure the node connecton object $node = new EstraierPure_Node; $node->set_url('http://*****:*****@uri', 'http://estraier.example.com/example.txt'); $doc->add_attr('@title', 'Bridge Over The Troubled Water'); // add the body text to the document object $doc->add_text('Like a bridge over the troubled water,'); $doc->add_text('I will ease your mind.'); // register the document object to the node if (!$node->put_doc($doc)) { fprintf(STDERR, "error: %d\n", $node->status()); if (EstraierPure_Utility::errorstack()->hasErrors()) { fputs(STDERR, print_r(EstraierPure_Utility::errorstack()->getErrors(), true)); } } else { fputs(STDOUT, "success.\n"); } ?>