// for postgres, we need to create
// - a stored procedure for mapping ISO language codes to PostgreSQL fulltext configuration names
// - if languages are not null, for each configured language as well as for the generic configuration
// an index over nodes.svalue
ScriptRunner runner = new ScriptRunner(connection.getJDBCConnection(), false, false);
if(connection.getMetadata("ft.lookup") == null) {
log.info("PostgreSQL: creating language configuration lookup function");
StringBuilder script = new StringBuilder();
for(String line : IOUtils.readLines(PostgreSQLDialect.class.getResourceAsStream("create_fulltext_langlookup.sql"))) {
if(!line.startsWith("--")) {
script.append(line);
script.append(" ");
}
}
log.debug("PostgreSQL: running SQL script '{}'", script.toString());
runner.runScript(new StringReader(script.toString()));
}
// language specific indexes
if(configuration.getFulltextLanguages() != null) {
StringBuilder script = new StringBuilder();
for(String line : IOUtils.readLines(PostgreSQLDialect.class.getResourceAsStream("create_fulltext_index.sql"))) {
if(!line.startsWith("--")) {
script.append(line);
script.append(" ");
}
}
for(String lang : configuration.getFulltextLanguages()) {
if(connection.getMetadata("ft.idx."+lang) == null) {
String pg_configuration = POSTGRES_LANG_MAPPINGS.get(lang);
if(pg_configuration != null) {
log.info("PostgreSQL: creating fulltext index for language {}", lang);
String script_lang = script.toString().replaceAll("@LANGUAGE@", lang).replaceAll("@CONFIGURATION@",pg_configuration);
log.debug("PostgreSQL: running SQL script '{}'", script_lang);
runner.runScript(new StringReader(script_lang));
}
}
}
}
// generic index
if(configuration.getFulltextLanguages() != null) {
if(connection.getMetadata("ft.idx.generic") == null) {
StringBuilder script = new StringBuilder();
for(String line : IOUtils.readLines(PostgreSQLDialect.class.getResourceAsStream("create_fulltext_index_generic.sql"))) {
if(!line.startsWith("--")) {
script.append(line);
script.append(" ");
}
}
log.info("PostgreSQL: creating generic fulltext index ");
log.debug("PostgreSQL: running SQL script '{}'", script.toString());
runner.runScript(new StringReader(script.toString()));
}
}
/*
} else if(configuration.getDialect() instanceof MySQLDialect) {