# lcase it for comparison
$q = strtolower($q);
- $notice->whereAdd('MATCH(content) against (\''.addslashes($q).'\')');
+
+ if(common_config('db','type')=='mysql') {
+ $notice->whereAdd('MATCH(content) against (\''.addslashes($q).'\')');
+ } else {
+ $notice->whereAdd('to_tsvector(\'english\', content) @@ plainto_tsquery(\''.addslashes($q).'\')');
+ }
# Ask for an extra to see if there's more.
# lcase it for comparison
$q = strtolower($q);
- $notice->whereAdd('MATCH(content) against (\''.addslashes($q).'\')');
+ if(common_config('db','type')=='mysql') {
+ $notice->whereAdd('MATCH(content) against (\''.addslashes($q).'\')');
+ } else {
+ $notice->whereAdd('to_tsvector(\'english\',content) @@ plainto_tsquery(\''.addslashes($q).'\')');
+ }
$notice->orderBy('created DESC, notice.id DESC');
# Ask for an extra to see if there's more.
function get_image() {
return NULL;
}
-}
\ No newline at end of file
+}
# lcase it for comparison
$q = strtolower($q);
- $profile->whereAdd('MATCH(nickname, fullname, location, bio, homepage) ' .
+
+ if(common_config('db','type')=='mysql') {
+ $profile->whereAdd('MATCH(nickname, fullname, location, bio, homepage) ' .
'against (\''.addslashes($q).'\')');
+ } else {
+ $profile->whereAdd('textsearch @@ plainto_tsquery(\''.addslashes($q).'\')');
+ }
# Ask for an extra to see if there's more.
bio varchar(140) /* comment 'descriptive biography' */,\r
location varchar(255) /* comment 'physical location' */,\r
created timestamp not null /* comment 'date this record was created' */,\r
- modified timestamp /* comment 'date this record was modified' */\r
+ modified timestamp /* comment 'date this record was modified' */,\r
\r
-/* FULLTEXT(nickname, fullname, location, bio, homepage) */\r
+ textsearch tsvector\r
);\r
create index profile_nickname_idx on profile using btree(nickname);\r
\r
-\r
-\r
create table avatar (\r
profile_id integer not null /* comment 'foreign key to profile table' */ references profile (id) ,\r
original integer default 0 /* comment 'uploaded by user or generated?' */,\r
);\r
create index foreign_subscription_subscriber_idx on foreign_subscription using btree(subscriber);\r
create index foreign_subscription_subscribed_idx on foreign_subscription using btree(subscribed);\r
+\r
+/* Textsearch stuff */\r
+\r
+create index textsearch_idx on profile using gist(textsearch);\r
+create index noticecontent_idx on notice using gist(to_tsvector('english',content));\r
+create trigger textsearchupdate before insert or update on profile for each row\r
+execute procedure tsvector_update_trigger(textsearch, 'pg_catalog.english', nickname, fullname, location, bio, homepage);\r
+\r