| 148 | # Feature test for MatchDecider |
| 149 | $doc = new XapianDocument(); |
| 150 | $doc->set_data("Two"); |
| 151 | $doc->add_posting($stem->apply("out"), 1); |
| 152 | $doc->add_posting($stem->apply("outside"), 1); |
| 153 | $doc->add_posting($stem->apply("source"), 2); |
| 154 | $doc->add_value(0, "yes"); |
| 155 | $db->add_document($doc); |
| 156 | |
| 157 | class testmatchdecider extends XapianMatchDecider { |
| 158 | function apply($doc) { |
| 159 | # FIXME: workaround missing object wrapping in generated wrappers. |
| 160 | if (is_resource($doc)) $doc = new XapianDocument($doc); |
| 161 | return ($doc->get_value(0) == "yes"); |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | $query = new XapianQuery($stem->apply("out")); |
| 166 | $enquire = new XapianEnquire($db); |
| 167 | $enquire->set_query($query); |
| 168 | $mdecider = new testmatchdecider(); |
| 169 | $mset = $enquire->get_mset(0, 10, null, $mdecider); |
| 170 | if ($mset->size() != 1) { |
| 171 | print "Unexpected number of documents returned by match decider (".$mset->size().")\n"; |
| 172 | exit(1); |
| 173 | } |
| 174 | if ($mset->get_docid(0) != 2) { |
| 175 | print "MatchDecider mset has wrong docid in\n"; |
| 176 | } |
| 177 | |