function SearchTsearch2( &$db ) {
$this->db =& $db;
$this->db->setSchema('tsearch');
+ $this->mRanking = true;
}
function getIndexField( $fulltext ) {
$searchon = preg_replace('/(\s+)/','&',$searchon);
$searchon = $this->db->strencode( $searchon );
+ return $searchon;
+ }
+
+ function queryRanking($filteredTerm, $fulltext) {
$field = $this->getIndexField( $fulltext );
- return " $field @@ to_tsquery('$searchon')";
+ $searchon = $this->parseQuery($filteredTerm,$fulltext);
+ if ($this->mRanking)
+ return " ORDER BY rank($field,to_tsquery('$searchon')) DESC";
+ else
+ return "";
}
+
function queryMain( $filteredTerm, $fulltext ) {
$match = $this->parseQuery( $filteredTerm, $fulltext );
+ $field = $this->getIndexField( $fulltext );
$cur = $this->db->tableName( 'cur' );
$searchindex = $this->db->tableName( 'searchindex' );
return 'SELECT cur_id, cur_namespace, cur_title, cur_text ' .
"FROM $cur,$searchindex " .
- 'WHERE cur_id=si_page AND ' . $match;
+ 'WHERE cur_id=si_page AND ' .
+ " $field @@ to_tsquery ('$match') " ;
}
function update( $id, $title, $text ) {