Hi everyone,
I tried sending a message as a reply a while back on my previous topic, but it
didn't go through. (Tried Gmane), not even when I 'authorized' the
reply. So I'll just paste it here for reference, below this message. It
might help some people. But now I have one other small problem, and I'm not
sure if it is actually my mistake (although I'm pretty sure it is :))
I'm trying to use the XapianQueryParser (in PHP5), but I get an error
everytime.
$odb = new XapianDatabase($db);
$ostem = new XapianStem("en");
$oqparser = new
XapianQueryParser();$oqparser->set_stemmer($ostem);$oqparser->set_database($odb);$oqparser->set_stemming_strategy(1);$oqparser->add_boolean_prefix("Q",1);$oquery
= $oqparser->parse_query($query, 1);
I found some perl examples and 'ported' it over to the PHP version.
Varying the flags (like XapianQueryParser::FLAG_PHRASE) or the boolean_prefix,
etc. does not influence anything. I tried to lcoate the error in Xapian.php, but
I think the error can be a bit deeper... I can query using XapianQuery, with a
single keyword.
Fatal error: No matching function for overloaded 'new_Query' in
/var/www/htdocs/almar/xapian.php on line 1123
Which is this function in XapianQuery
function
__construct($tname_or_op__or_copyme_or_op=null,$wqf_or_left_or_subqs_or_q=1,$term_pos_or_right_or_param=0)
{ switch (func_num_args()) { case 0: $r=new_Query(); break;--> this line:
default:
$r=new_Query($tname_or_op__or_copyme_or_op,$wqf_or_left_or_subqs_or_q,$term_pos_or_right_or_param);
} $this->_cPtr=$r; }
Anyone with suggestions? Many thanks already :).
Thanks.
----Other message:----
(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=keywordsdesc: unhtml index lower
truncate=255 field=desc url: unhtml field=url unique=Q boolean=Qcontent: 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 :)
NOTE: I think I got this fixed by using a 'value' field in Omega. Now I
can get the individual values of titles, url's, etc. Is there any bad thing
about doing it this way?