John Wards
2006-Jan-16 10:56 UTC
[Xapian-discuss] More fun and games with the PHP bindings
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
James Aylett
2006-Jan-16 11:16 UTC
[Xapian-discuss] More fun and games with the PHP bindings
On Mon, Jan 16, 2006 at 10:56:17AM +0000, John Wards wrote:> What is omega doing that I am not in my PHP code?Stemming? (I can't tell without seeing your omega template.) J -- /--------------------------------------------------------------------------\ James Aylett xapian.org james@tartarus.org uncertaintydivision.org
Olly Betts
2006-Jan-16 11:18 UTC
[Xapian-discuss] More fun and games with the PHP bindings
On Mon, Jan 16, 2006 at 10:56:17AM +0000, John Wards wrote:> $query = queryparser_parse_query ($query_parser, '"castle eden"');This is a phrase search (because of the "").> http://cms.octoberdevelopment.co.uk/cgi-bin/omega?P=castle+eden&DEFAULTOP=and&DB=boris&FMT=query&B=XSOLD0&B=XUNDER0This isn't a phrase search. The equivalent Omega search would be: http://cms.octoberdevelopment.co.uk/cgi-bin/omega?P=%22castle+eden%22&DEFAULTOP=and&DB=boris&FMT=query&B=XSOLD0&B=XUNDER0 For this sort of debugging, try adding this to your OmegaScript query template: $html{$querydescription} This expands to Query::get_description() on the query which omega builds, which you can then compare to the query you're building in PHP. Cheers, Olly