[Xapian-discuss] Re: Compiling PHP bindings with MingW/Windows

Any One fuzzylogictree at hotmail.com
Sun Nov 26 20:34:33 GMT 2006


(note: I try to post a follow-up through Gmane now, hope it all goes well!)

Hi Olly,

Thanks for your reply. Unfortunately I had no luck, and decided to test it on a 
linux machine. Compiling the core and Omega was not a problem, the PHP bindings 
(again) were problematic, but after a few hours it was all fixed and working. 
Some path issues.

I've moved over to PHP5 for Xapian. Right now everything is going quite 
smoothly. The data of my spider is nciely put in mySQL, and then a script 
transforms the data there to a scriptindex.exe readable format (I'm using that 
on my Windows machine, I can just exchange the DB's between linux/windows for 
now, great!). 

For anyone interested in some simple example code, check below. I've tried to 
convert a php4 example to the PHP5 one. 


My only problem right now is this:

keywords: unhtml index lower truncate=255 field=keywords
desc: unhtml index lower truncate=255 field=desc 
url: unhtml field=url unique=Q boolean=Q
content: unhtml weight=4 index field=content

This is the format for scriptindex. When I search my code with 

<?
include "xapian.php";
$db = "db/sitedb";

$odb = new XapianDatabase($db);
$ostem = new XapianStem("en");
$oquery  = new XapianQuery("visual");
$oenquire = new XapianEnquire($odb);
$oenquire->set_query($oquery);
echo "<pre>";

echo "Perform: " . $oquery->get_description() . "<br/>";
$omset = $oenquire->get_mset(0, 10);

echo "Matches: " . $omset->get_matches_estimated() . "<br/>";

$oiter = new XapianMSetIterator();
$oiter = $omset->begin();

while (!$oiter->equals($omset->end()))
{
	$odoc = $oiter->get_document();

	//Loop through values.
	echo  "Rank: " . $oiter->get_rank() . "<br/>";
	echo  "%: " .	 $oiter->get_percent()  . "<br/>";
	echo  "Desc: " . $oiter->get_description()  . "<br/>";
	
	$data = $odoc->get_data();
	echo $data;

	echo  $odoc->termlist_count() . "<br/>";
	echo  $odoc->values_count() . "<br/>";

	$ovalues = $odoc->values_begin();
	while (!$ovalues->equals($odoc->values_end()))
	{
		print_r($ovalues);

		$ovalues->next();
	}

	$oiter->next();
}

?>



I get nice results (great!). Except, I really, really want to have the 
individual values of the input data (keywords, description, url). I have found 
no way to do this, and the only funtion that seems to return it (alltogether) 
is get_data(). I thought "values" might be the solution, but those are just 
empty. I could not find anything in the manual. I know the cgi Omega demo seems 
to have a XML output template, which does about the same I guess (Do not have 
the opportunity to easily run the CGI bin demo's)

Could you possibly give me a hint on this one? 

Many thanks already :)




More information about the Xapian-discuss mailing list