/** * Create a fulltext search datatype for PostgreSQL * This will also return a trigger to be applied to this table * * @todo: create custom functions to allow weighted searches * * @param array $this_index Index specification for the fulltext index * @param string $tableName * @param string $name * @param array $spec */ protected function fulltext($this_index, $tableName, $name) { //For full text search, we need to create a column for the index $columns = $this->quoteColumnSpecString($this_index['value']); $fulltexts = "\"ts_{$name}\" tsvector"; $triggerName = $this->buildPostgresTriggerName($tableName, $name); $language = PostgreSQLDatabase::search_language(); $this->dropTrigger($triggerName, $tableName); $triggers = "CREATE TRIGGER \"{$triggerName}\" BEFORE INSERT OR UPDATE\n\t\t\t\t\tON \"{$tableName}\" FOR EACH ROW EXECUTE PROCEDURE\n\t\t\t\t\ttsvector_update_trigger(\"ts_{$name}\", 'pg_catalog.{$language}', {$columns});"; return array('name' => $name, 'ts_name' => "ts_{$name}", 'fulltexts' => $fulltexts, 'triggers' => $triggers); }