[Xapian-discuss] More fun and games with the PHP bindings

John Wards j.wards at sportnetwork.net
Mon Jan 16 10:56:17 GMT 2006


Morning All,

After cracking the ORing of my Bool filters I was about to launch my new
speedy search code on the public when I just thought I would try one
more search query..

My test code in full:
-------------------------------------------------
<?php
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime; 
$database = new_Database("/path/to/db/boris");
$enquire = new_Enquire($database);
$query_parser = new_queryparser();
queryparser_set_database ($query_parser, $database);
$query = queryparser_parse_query ($query_parser, '"castle eden"');
$query = new_Query_from_query_pair(Query_OP_FILTER, $query, new_Query("XSOLD0"));
$query = new_Query_from_query_pair(Query_OP_FILTER, $query, new_Query("XUNDER0"));

print "<pre>Performing query `" . Query_get_description($query) . "'\n";

Enquire_set_query($enquire, $query);
Enquire_set_sort_by_value($enquire,1,false);
$matches = Enquire_get_mset($enquire, 0, 10);
print MSet_get_matches_estimated($matches) . " results found\n";
$mseti = MSet_begin($matches);
while (! MSetIterator_equals($mseti, MSet_end($matches))) {
	print "ID " . MSetIterator_get_docid($mseti) . " " .
        MSetIterator_get_percent($mseti) . "% [" .
        Document_get_data(MSetIterator_get_document($mseti)) . "]\n";
    MSetIterator_next($mseti);
}
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$totaltime = ($endtime - $starttime);

echo $totaltime." Seconds<br>";
?>
-------------------------------------------
This results in the output of:
Performing query `Xapian::Query((((castle:(pos=1) PHRASE 2 eden:(pos=2)) FILTER XSOLD0) FILTER XUNDER0))'
0 results found
0.00148797035217 Seconds

If I use the web based omega interface for the exact same query on the
same db:

http://cms.octoberdevelopment.co.uk/cgi-bin/omega?P=castle+eden&DEFAULTOP=and&DB=boris&FMT=query&B=XSOLD0&B=XUNDER0

I get 3 results.

If I replace this line:
$query = queryparser_parse_query ($query_parser, '"castle eden"');

With:
$query = queryparser_parse_query ($query_parser, '"fir tree"');

I get the following out out (I have snipped it due to the length but you
get the idea)

Performing query `Xapian::Query((((fir:(pos=1) PHRASE 2 tree:(pos=2)) FILTER XSOLD0) FILTER XUNDER0))'
23 results found
ID 15834 88% [added=1137337856
caption= Harperley Terrace, Fir Tree, County Durham
id=9806997
image=http://www2.vebra.com/robinsons/crook/sales/ecimage0/7harperleyterrace.jpg
price=72000
propid=9806997
sample=Located within this well established village, we have pleasure in offering for sale, a TWO BEDROOM MID TERRACED PROPERTY, which we feel should prove popular to the first time buyers.  Offering good sized accommodation, having the added benefits of DOUBLE GLAZING and COAL FIRE which should prove economical to maintain.  The accommodation briefly comprises of ENTRANCE PORCH, LOUNGE, KITCHEN, GROUND FLOOR BATHROOM in coloured suite and to the first floor TWO BEDROOMS.  Externally the property is offered with on street parking to the front, whilst to the rear is an ENCLOSED YARD.
sortprice=00072000
url=http://www.vebra.com/home/search/vdetails.asp?src=vebra&fd=0&bd=1&db=1&cl=2356&pid=9806997
]

What is omega doing that I am not in my PHP code?

Cheers
John




More information about the Xapian-discuss mailing list