[Fusionforge-commits] r14572 - in branches/Branch_5_1: . src/common/search
Roland Mas
lolando at fusionforge.org
Fri Oct 7 16:31:22 CEST 2011
Author: lolando
Date: 2011-10-07 16:31:22 +0200 (Fri, 07 Oct 2011)
New Revision: 14572
Modified:
branches/Branch_5_1/
branches/Branch_5_1/src/common/search/NewsSearchQuery.class.php
Log:
Fix cross-field searches for news
Modified: branches/Branch_5_1/src/common/search/NewsSearchQuery.class.php
===================================================================
--- branches/Branch_5_1/src/common/search/NewsSearchQuery.class.php 2011-10-07 14:31:13 UTC (rev 14571)
+++ branches/Branch_5_1/src/common/search/NewsSearchQuery.class.php 2011-10-07 14:31:22 UTC (rev 14572)
@@ -61,33 +61,26 @@
$words = $this->getFTIwords();
$qpa = db_construct_qpa ($qpa,
- 'SELECT ts_headline(news_bytes.summary, q) as summary, news_bytes.post_date, news_bytes.forum_id, users.realname FROM news_bytes, users, to_tsquery($1) AS q, news_bytes_idx WHERE (news_bytes.group_id=$2 AND news_bytes.is_approved <> 4 AND news_bytes_idx.id = news_bytes.id AND news_bytes.submitted_by=users.user_id) AND (vectors @@ q ',
- array ($words,
+ 'SELECT x.* FROM (SELECT ts_headline(news_bytes.summary, q) as summary, news_bytes.post_date, news_bytes.forum_id, users.realname, summary||$1||details AS full_string_agg, news_bytes_idx.vectors FROM news_bytes, users, to_tsquery($2) AS q, news_bytes_idx WHERE (news_bytes.group_id=$3 AND news_bytes.is_approved <> 4 AND news_bytes_idx.id = news_bytes.id AND news_bytes.submitted_by=users.user_id) AND vectors @@ q) AS x ',
+ array (' //// ',
+ $words,
$group_id)) ;
if (count ($this->phrases)) {
$qpa = db_construct_qpa ($qpa,
- $this->getOperator()) ;
- $qpa = db_construct_qpa ($qpa,
- ' ((') ;
- $qpa = $this->addMatchCondition ($qpa, 'summary') ;
- $qpa = db_construct_qpa ($qpa,
- ') OR (') ;
- $qpa = $this->addMatchCondition ($qpa, 'details') ;
- $qpa = db_construct_qpa ($qpa,
- '))') ;
+ 'WHERE ');
+ $qpa = $this->addMatchCondition ($qpa, 'full_string_agg') ;
}
$qpa = db_construct_qpa ($qpa,
- ') ORDER BY ts_rank(vectors, q) DESC, post_date DESC') ;
+ ' ORDER BY ts_rank(vectors, $1) DESC, post_date DESC',
+ array($words)) ;
} else {
$qpa = db_construct_qpa ($qpa,
- 'SELECT news_bytes.summary, news_bytes.post_date, news_bytes.forum_id, users.realname FROM news_bytes, users WHERE group_id=$1 AND is_approved <> 4 AND news_bytes.submitted_by = users.user_id AND ((',
- array ($this->groupId)) ;
- $qpa = $this->addIlikeCondition ($qpa, 'summary') ;
+ 'SELECT x.* FROM (SELECT news_bytes.summary, news_bytes.post_date, news_bytes.forum_id, users.realname, summary||$1||details AS full_string_agg FROM news_bytes, users WHERE group_id=$2 AND is_approved <> 4 AND news_bytes.submitted_by = users.user_id) AS x WHERE ',
+ array (' //// ',
+ $this->groupId)) ;
+ $qpa = $this->addIlikeCondition ($qpa, 'full_string_agg') ;
$qpa = db_construct_qpa ($qpa,
- ') OR (') ;
- $qpa = $this->addIlikeCondition ($qpa, 'details') ;
- $qpa = db_construct_qpa ($qpa,
- ')) ORDER BY post_date DESC') ;
+ ' ORDER BY post_date DESC') ;
}
return $qpa ;
}
More information about the Fusionforge-commits
mailing list