[mb-commits] r13707 - in search_server/trunk/index/src: main/java/org/musicbrainz/search/index test/java/org/musicbrainz/search/index

[email protected] Thu, 26 Sep 2013 14:45:47 +0000
Newsgroups gmane.comp.audio.musicbrainz.cvs
Message-ID <E1VPCp9-0005dC-OX@wiley>
Author: ijabz
Date: 2013-09-26 14:45:34 +0000 (Thu, 26 Sep 2013)
New Revision: 13707

Modified:
   search_server/trunk/index/src/main/java/org/musicbrainz/search/index/AnnotationIndex.java
   search_server/trunk/index/src/main/java/org/musicbrainz/search/index/ArtistIndex.java
   search_server/trunk/index/src/main/java/org/musicbrainz/search/index/CommonTables.java
   search_server/trunk/index/src/main/java/org/musicbrainz/search/index/LabelIndex.java
   search_server/trunk/index/src/main/java/org/musicbrainz/search/index/RecordingIndex.java
   search_server/trunk/index/src/main/java/org/musicbrainz/search/index/ReleaseGroupIndex.java
   search_server/trunk/index/src/main/java/org/musicbrainz/search/index/ReleaseIndex.java
   search_server/trunk/index/src/main/java/org/musicbrainz/search/index/WorkIndex.java
   search_server/trunk/index/src/test/java/org/musicbrainz/search/index/AbstractIndexTest.java
   search_server/trunk/index/src/test/java/org/musicbrainz/search/index/AnnotationIndexTest.java
   search_server/trunk/index/src/test/java/org/musicbrainz/search/index/ArtistIndexTest.java
   search_server/trunk/index/src/test/java/org/musicbrainz/search/index/LabelIndexTest.java
   search_server/trunk/index/src/test/java/org/musicbrainz/search/index/RecordingIndexTest.java
   search_server/trunk/index/src/test/java/org/musicbrainz/search/index/ReleaseGroupIndexTest.java
   search_server/trunk/index/src/test/java/org/musicbrainz/search/index/ReleaseIndexTest.java
   search_server/trunk/index/src/test/java/org/musicbrainz/search/index/WorkIndexTest.java
Log:
SEARCH-318:Update indexing for _name table removal, made changes to code and test, not yet tested against the real thing

Modified: search_server/trunk/index/src/main/java/org/musicbrainz/search/index/AnnotationIndex.java
===================================================================
--- search_server/trunk/index/src/main/java/org/musicbrainz/search/index/AnnotationIndex.java	2013-09-26 12:49:38 UTC (rev 13706)
+++ search_server/trunk/index/src/main/java/org/musicbrainz/search/index/AnnotationIndex.java	2013-09-26 14:45:34 UTC (rev 13707)
@@ -16,10 +16,9 @@
     // Private class for storing specific information about each annotation type
     private class AnnotationTypeInfo {
         public String entityDbName;
-        public String nameTable;
-        public AnnotationTypeInfo(String entityDbName, String nameTable) {
+
+        public AnnotationTypeInfo(String entityDbName) {
             this.entityDbName = entityDbName;
-            this.nameTable = nameTable;
         }
     }
     protected EnumMap<AnnotationType, AnnotationTypeInfo> annotationTypeInfos;
@@ -57,18 +56,18 @@
 
         // Register all information for each annotation type
         annotationTypeInfos = new EnumMap<AnnotationType, AnnotationTypeInfo>(AnnotationType.class);
-        annotationTypeInfos.put(AnnotationType.ARTIST, new AnnotationTypeInfo("artist", "artist_name"));
-        annotationTypeInfos.put(AnnotationType.LABEL, new AnnotationTypeInfo("label", "label_name"));
-        annotationTypeInfos.put(AnnotationType.RECORDING, new AnnotationTypeInfo("recording", "track_name"));
-        annotationTypeInfos.put(AnnotationType.RELEASE, new AnnotationTypeInfo("release", "release_name"));
-        annotationTypeInfos.put(AnnotationType.RELEASE_GROUP, new AnnotationTypeInfo("release_group", "release_name"));
-        annotationTypeInfos.put(AnnotationType.WORK, new AnnotationTypeInfo("work", "work_name"));
+        annotationTypeInfos.put(AnnotationType.ARTIST, new AnnotationTypeInfo("artist"));
+        annotationTypeInfos.put(AnnotationType.LABEL, new AnnotationTypeInfo("label"));
+        annotationTypeInfos.put(AnnotationType.RECORDING, new AnnotationTypeInfo("recording"));
+        annotationTypeInfos.put(AnnotationType.RELEASE, new AnnotationTypeInfo("release"));
+        annotationTypeInfos.put(AnnotationType.RELEASE_GROUP, new AnnotationTypeInfo("release_group"));
+        annotationTypeInfos.put(AnnotationType.WORK, new AnnotationTypeInfo("work"));
         
         // Build prepared statement for each annotation type
         for (AnnotationType type : annotationTypeInfos.keySet()) {
             AnnotationTypeInfo info = annotationTypeInfos.get(type);
             addPreparedStatement(type.getName(), 
-                "SELECT a.id, e.gid, a.text, en.name " +
+                "SELECT a.id, e.gid, a.text, e.name " +
                 " FROM annotation a " +
                 "  INNER JOIN " + info.entityDbName + "_annotation ea ON a.id=ea.annotation " +
                 "  INNER JOIN (SELECT DISTINCT ea2." + info.entityDbName + " as id, max(created) as created_date " +
@@ -76,7 +75,6 @@
                 "                INNER JOIN " + info.entityDbName + "_annotation ea2 on a2.id=ea2.annotation GROUP BY ea2." + info.entityDbName +
                 "              ) AS last_ann ON ea." + info.entityDbName + "=last_ann.id AND a.created=last_ann.created_date "  +
                 "  INNER JOIN " + info.entityDbName + " e ON ea." + info.entityDbName + "=e.id " +
-                "  INNER JOIN " + info.nameTable + " en ON e.name=en.id " +
                 " WHERE a.id BETWEEN ? and ? AND length(a.text) > 0"
             );
         }

Modified: search_server/trunk/index/src/main/java/org/musicbrainz/search/index/ArtistIndex.java
===================================================================
--- search_server/trunk/index/src/main/java/org/musicbrainz/search/index/ArtistIndex.java	2013-09-26 12:49:38 UTC (rev 13706)
+++ search_server/trunk/index/src/main/java/org/musicbrainz/search/index/ArtistIndex.java	2013-09-26 14:45:34 UTC (rev 13707)
@@ -109,24 +109,21 @@
                         " WHERE artist between ? AND ?");
 
         addPreparedStatement("ALIASES",
-                "SELECT a.artist as artist, n.name as alias, sn.name as alias_sortname, a.primary_for_locale, a.locale, att.name as type," +
+                "SELECT a.artist as artist, a.name as alias, a.sort_name as alias_sortname, a.primary_for_locale, a.locale, att.name as type," +
                         "a.begin_date_year, a.begin_date_month, a.begin_date_day, a.end_date_year, a.end_date_month, a.end_date_day" +
                         " FROM artist_alias a" +
-                        "  JOIN artist_name n ON (a.name = n.id) " +
-                        "  JOIN artist_name sn ON (a.sort_name = sn.id) " +
                         "  LEFT JOIN artist_alias_type att on (a.type=att.id)" +
                         " WHERE artist BETWEEN ? AND ?" +
                         " ORDER BY artist, alias, alias_sortname");
 
         addPreparedStatement("ARTISTCREDITS",
-                        "SELECT artist as artist, n.name as artistcredit " +
+                        "SELECT artist as artist, name as artistcredit " +
                         " FROM artist_credit_name " +
-                        "  JOIN artist_name n ON n.id = artist_credit_name.name " +
                         " WHERE artist BETWEEN ? AND ? ");
 
 
         addPreparedStatement("ARTISTS",
-                "SELECT a.id, a.gid as gid, n0.name as name, n1.name as sort_name, " +
+                "SELECT a.id, a.gid as gid, a.name, a.sort_name, " +
                         "  artist_type.name as type, a.begin_date_year, a.begin_date_month, a.begin_date_day, " +
                         "  a.end_date_year, a.end_date_month, a.end_date_day,a.ended, " +
                         "  comment, lower(i.code) as country, lower(gender.name) as gender," +
@@ -134,8 +131,6 @@
                         "  a2.gid as beginarea_gid, a2.name as beginarea_name, a2.sort_name as beginarea_sortname, " +
                         "  a3.gid as endarea_gid, a3.name as endarea_name, a3.sort_name as endarea_sortname" +
                         " FROM artist a " +
-                        "  LEFT JOIN artist_name n0 ON a.name = n0.id " +
-                        "  LEFT JOIN artist_name n1 ON a.sort_name = n1.id " +
                         "  LEFT JOIN artist_type ON a.type = artist_type.id " +
                         "  LEFT JOIN iso_3166_1 i on a.area=i.area" +
                         "  LEFT JOIN gender ON a.gender=gender.id " +

Modified: search_server/trunk/index/src/main/java/org/musicbrainz/search/index/CommonTables.java
===================================================================
--- search_server/trunk/index/src/main/java/org/musicbrainz/search/index/CommonTables.java	2013-09-26 12:49:38 UTC (rev 13706)
+++ search_server/trunk/index/src/main/java/org/musicbrainz/search/index/CommonTables.java	2013-09-26 14:45:34 UTC (rev 13707)
@@ -70,19 +70,15 @@
                 "  acn.join_phrase as joinphrase, " +
                 "  a.gid as artistId,  " +
                 "  a.comment as comment, " +
-                "  an.name as artistName, " +
-                "  an2.name as artistCreditName, " +
-                "  an3.name as artistSortName, " +
+                "  a.name as artistName, " +
+                "  acn.name as artistCreditName, " +
+                "  a.sort_name as artistSortName, " +
                 "  aa1.aliasName " +
                 " FROM artist_credit_name acn  " +
                 "  INNER JOIN artist a ON a.id=acn.artist " +
-                "  INNER JOIN artist_name an ON a.name=an.id " +
-                "  INNER JOIN artist_name an2 ON acn.name=an2.id " +
-                "  INNER JOIN artist_name an3 ON a.sort_name=an3.id " +
-                "  LEFT JOIN ( SELECT aa.artist, MAX(an4.name) AS aliasName FROM" +
+                "  LEFT JOIN ( SELECT aa.artist, MAX(aa.name) AS aliasName FROM" +
                 "     artist_alias aa " +
-                "     INNER JOIN artist_name an4 ON aa.name=an4.id " +
-                    "     WHERE aa.locale='" + ENGLISH_ISO_CODE + "'" +
+                "     WHERE aa.locale='" + ENGLISH_ISO_CODE + "'" +
                 "     GROUP BY aa.artist) AS aa1"  +
                 "     ON a.id=aa1.artist " +
                 " ORDER BY acn.artist_credit,acn.position ");
@@ -139,7 +135,7 @@
 
         getDbConnection().createStatement().execute(
             "CREATE TEMPORARY TABLE tmp_release AS " +
-                "SELECT r.id, r.gid, rn.name as name, " +
+                "SELECT r.id, r.gid, r.name as name, " +
                 "  barcode, " +
                 "  rgt.name as type, rg.id as rg_id, rg.gid as rg_gid, rm.amazon_asin, " +
                 "  language.iso_code_3 as language, language.iso_code_2t as language_2t, script.iso_code as script, rs.name as status, " +
@@ -150,12 +146,11 @@
                 "  LEFT JOIN release_meta rm ON r.id = rm.id " +
                 "  LEFT JOIN release_group rg ON rg.id = r.release_group " +
                 "  LEFT JOIN release_group_primary_type rgt  ON rg.type = rgt.id " +
-                "  LEFT JOIN release_name rn ON r.name = rn.id " +
                 "  LEFT JOIN release_status rs ON r.status = rs.id " +
                 "  LEFT JOIN language ON r.language=language.id " +
                 "  LEFT JOIN script ON r.script=script.id " +
                 "  LEFT JOIN medium m ON m.release=r.id" +
-                " GROUP BY r.id,r.gid,rn.name,barcode,rgt.name,rg.id, rg.gid," +
+                " GROUP BY r.id,r.gid,r.name,barcode,rgt.name,rg.id, rg.gid," +
                 "  rm.amazon_asin, language.iso_code_3, language.iso_code_2t, script.iso_code,rs.name,r.artist_credit, r.comment");
         clock.stop();
         System.out.println("tmp_release     :Finished:" + Utils.formatClock(clock));
@@ -210,10 +205,9 @@
 
         getDbConnection().createStatement().execute(
             "CREATE TEMPORARY TABLE tmp_track AS " +
-                "SELECT t.id, t.gid, t.recording, t.length, tn.name as track_name, t.position as track_position, t.number as track_number, m.track_count, " +
+                "SELECT t.id, t.gid, t.recording, t.length, t.name as track_name, t.position as track_position, t.number as track_number, m.track_count, " +
                 "  m.release as release_id, m.position as medium_position, mf.name as format " +
                 " FROM track t " +
-                "  INNER JOIN track_name tn ON t.name=tn.id" +
                 "  INNER JOIN medium m ON t.medium=m.id " +
                 "  LEFT JOIN  medium_format mf ON m.format=mf.id ");
 

Modified: search_server/trunk/index/src/main/java/org/musicbrainz/search/index/LabelIndex.java
===================================================================
--- search_server/trunk/index/src/main/java/org/musicbrainz/search/index/LabelIndex.java	2013-09-26 12:49:38 UTC (rev 13706)
+++ search_server/trunk/index/src/main/java/org/musicbrainz/search/index/LabelIndex.java	2013-09-26 14:45:34 UTC (rev 13707)
@@ -93,25 +93,21 @@
                 " WHERE label between ? AND ?");
 
         addPreparedStatement("ALIASES",
-                "SELECT a.label as label, n.name as alias, sn.name as alias_sortname, a.primary_for_locale, a.locale, att.name as type," +
+                "SELECT a.label as label, a.name as alias, a.sort_name as alias_sortname, a.primary_for_locale, a.locale, att.name as type," +
                         "a.begin_date_year, a.begin_date_month, a.begin_date_day, a.end_date_year, a.end_date_month, a.end_date_day" +
                         " FROM label_alias a" +
-                        "  JOIN label_name n ON (a.name = n.id) " +
-                        "  JOIN label_name sn ON (a.sort_name = sn.id) " +
                         "  LEFT JOIN label_alias_type att on (a.type=att.id)" +
                         " WHERE label BETWEEN ? AND ?" +
                         " ORDER BY label, alias, alias_sortname");
 
 
         addPreparedStatement("LABELS",
-                "SELECT label.id, label.gid, n0.name as name, n1.name as sort_name, " +
+                "SELECT label.id, label.gid, label.name as name, label.sort_name, " +
                 "  label_type.name as type, label.begin_date_year, label.begin_date_month, label.begin_date_day, " +
                 "  label.end_date_year, label.end_date_month, label.end_date_day, label.ended," +
                 "  comment, label_code, lower(i.code) as country, " +
                 "  a1.gid as area_gid, a1.name as area_name, a1.sort_name as area_sortname " +
                 " FROM label " +
-                "  LEFT JOIN label_name n0 ON label.name = n0.id " +
-                "  LEFT JOIN label_name n1 ON label.sort_name = n1.id " +
                 "  LEFT JOIN label_type ON label.type = label_type.id " +
                 "  LEFT JOIN iso_3166_1 i on label.area=i.area" +
                 "  LEFT JOIN area a1 on label.area = a1.id" +

Modified: search_server/trunk/index/src/main/java/org/musicbrainz/search/index/RecordingIndex.java
===================================================================
--- search_server/trunk/index/src/main/java/org/musicbrainz/search/index/RecordingIndex.java	2013-09-26 12:49:38 UTC (rev 13706)
+++ search_server/trunk/index/src/main/java/org/musicbrainz/search/index/RecordingIndex.java	2013-09-26 14:45:34 UTC (rev 13707)
@@ -138,12 +138,12 @@
                             " AND   recording between ? AND ?");
 
             addPreparedStatement("TRACKS",
-                    "SELECT t.id, t.gid, tn.name as track_name, t.length as duration, t.recording, t.position as track_position, t.number as track_number, m.track_count, " +
+                    "SELECT t.id, t.gid, t.name as track_name, t.length as duration, t.recording, t.position as track_position, t.number as track_number, m.track_count, " +
                             "  m.release as release_id, m.position as medium_position,mf.name as format " +
                             " FROM track t " +
-                            "  INNER JOIN track_name tn ON t.name=tn.id AND t.recording BETWEEN ? AND ?" +
                             "  INNER JOIN medium m ON t.medium=m.id " +
-                            "  LEFT JOIN  medium_format mf ON m.format=mf.id "
+                            "  LEFT JOIN  medium_format mf ON m.format=mf.id " +
+                            " WHERE t.recording BETWEEN ? AND ?"
             );
         }
 
@@ -214,10 +214,9 @@
                         " WHERE r.id in ";
 
         addPreparedStatement("RECORDINGS",
-                "SELECT re.id as recordingId, re.gid as trackid, re.length as duration, tn.name as trackname, re.comment " +
+                "SELECT re.id as recordingId, re.gid as trackid, re.length as duration, re.name as trackname, re.comment " +
                         " FROM recording re " +
-                        "  INNER JOIN track_name tn ON re.name=tn.id " +
-                        "  AND re.id BETWEEN ? AND ?");
+                        " WHERE re.id BETWEEN ? AND ?");
     }
 
     public void destroy() throws SQLException {

Modified: search_server/trunk/index/src/main/java/org/musicbrainz/search/index/ReleaseGroupIndex.java
===================================================================
--- search_server/trunk/index/src/main/java/org/musicbrainz/search/index/ReleaseGroupIndex.java	2013-09-26 12:49:38 UTC (rev 13706)
+++ search_server/trunk/index/src/main/java/org/musicbrainz/search/index/ReleaseGroupIndex.java	2013-09-26 14:45:34 UTC (rev 13707)
@@ -99,9 +99,8 @@
 
 
         addPreparedStatement("RELEASES",
-                "SELECT DISTINCT release_group, release.gid as gid, n0.name as name, rs.name as status " +
+                "SELECT DISTINCT release_group, release.gid as gid, release.name, rs.name as status " +
                 " FROM release " +
-                "  LEFT JOIN release_name n0 ON release.name = n0.id " +
                 "  LEFT JOIN release_status rs ON release.status = rs.id " +
                 " WHERE release_group BETWEEN ? AND ?");
 
@@ -129,9 +128,8 @@
                 " WHERE rgj.release_group BETWEEN ? AND ?");
 
         addPreparedStatement("RELEASEGROUPS",
-                "SELECT rg.id, rg.gid, n0.name as name, release_group_primary_type.name as type, rg.comment " +
+                "SELECT rg.id, rg.gid, rg.name as name, release_group_primary_type.name as type, rg.comment " +
                 " FROM release_group AS rg " +
-                "  LEFT JOIN release_name n0 ON rg.name = n0.id " +
                 "  LEFT JOIN release_group_primary_type ON rg.type = release_group_primary_type.id " +
                 " WHERE rg.id BETWEEN ? AND ?" +
                 " ORDER BY rg.id");

Modified: search_server/trunk/index/src/main/java/org/musicbrainz/search/index/ReleaseIndex.java
===================================================================
--- search_server/trunk/index/src/main/java/org/musicbrainz/search/index/ReleaseIndex.java	2013-09-26 12:49:38 UTC (rev 13706)
+++ search_server/trunk/index/src/main/java/org/musicbrainz/search/index/ReleaseIndex.java	2013-09-26 14:45:34 UTC (rev 13707)
@@ -122,10 +122,9 @@
         }
 
         addPreparedStatement("LABELINFOS",
-               "SELECT rl.release as releaseId, l.gid as labelId, ln.name as labelName, catalog_number " +
+               "SELECT rl.release as releaseId, l.gid as labelId, l.name as labelName, catalog_number " +
                " FROM release_label rl " +
                "  LEFT JOIN label l ON rl.label=l.id " +
-               "  LEFT JOIN label_name ln ON l.name = ln.id " +
                " WHERE rl.release BETWEEN ? AND ?");
 
         addPreparedStatement("MEDIUMS",

Modified: search_server/trunk/index/src/main/java/org/musicbrainz/search/index/WorkIndex.java
===================================================================
--- search_server/trunk/index/src/main/java/org/musicbrainz/search/index/WorkIndex.java	2013-09-26 12:49:38 UTC (rev 13706)
+++ search_server/trunk/index/src/main/java/org/musicbrainz/search/index/WorkIndex.java	2013-09-26 14:45:34 UTC (rev 13707)
@@ -82,13 +82,11 @@
                         " WHERE work between ? AND ?");
 
         addPreparedStatement("ARTISTS",
-                " SELECT aw.id as awid, l.id as lid, w.id as wid, w.gid, a.gid as aid, an.name as artist_name, sn.name as artist_sortname," +
+                " SELECT aw.id as awid, l.id as lid, w.id as wid, w.gid, a.gid as aid, a.name as artist_name, a.sort_name as artist_sortname," +
                         " lt.name as link, lat.name as attribute" +
                         " FROM l_artist_work aw" +
                         " INNER JOIN artist a ON a.id    = aw.entity0" +
                         " INNER JOIN work   w ON w.id     = aw.entity1" +
-                        " INNER JOIN artist_name an ON an.id = a.name" +
-                        " INNER JOIN artist_name sn ON sn.id = a.sort_name" +
                         " INNER JOIN link l ON aw.link = l.id " +
                         " INNER JOIN link_type lt on l.link_type=lt.id" +
                         " LEFT JOIN  link_attribute la on la.link=l.id" +
@@ -97,9 +95,8 @@
                         " ORDER BY aw.id");
 
         addPreparedStatement("ALIASES",
-                "SELECT work_alias.work as work, n.name as alias " +
+                "SELECT work_alias.work as work, work_alias.name as alias " +
                         " FROM work_alias " +
-                        "  JOIN work_name n ON (work_alias.name = n.id) " +
                         " WHERE work BETWEEN ? AND ?");
 
         addPreparedStatement("ISWCS",
@@ -108,9 +105,8 @@
                         " WHERE work BETWEEN ? AND ?");
 
         addPreparedStatement("WORKS",
-                "SELECT w.id as wid, w.gid, wn.name as name, wt.name as type, l.iso_code_3 as language, comment " +
+                "SELECT w.id as wid, w.gid, w.name as name, wt.name as type, l.iso_code_3 as language, comment " +
                         " FROM work AS w " +
-                        "  LEFT JOIN work_name wn ON w.name = wn.id " +
                         "  LEFT JOIN work_type wt ON w.type = wt.id " +
                         "  LEFT JOIN language l on w.language = l.id " +
                         " WHERE w.id BETWEEN ? AND ? " +

Modified: search_server/trunk/index/src/test/java/org/musicbrainz/search/index/AbstractIndexTest.java
===================================================================
--- search_server/trunk/index/src/test/java/org/musicbrainz/search/index/AbstractIndexTest.java	2013-09-26 12:49:38 UTC (rev 13706)
+++ search_server/trunk/index/src/test/java/org/musicbrainz/search/index/AbstractIndexTest.java	2013-09-26 14:45:34 UTC (rev 13707)
@@ -117,7 +117,6 @@
                 stmt.addBatch("DROP TABLE artist");
                 stmt.addBatch("DROP TABLE artist_alias");
                 stmt.addBatch("DROP TABLE artist_alias_type");
-                stmt.addBatch("DROP TABLE artist_name");
                 stmt.addBatch("DROP TABLE artist_type");
                 stmt.addBatch("DROP TABLE artist_credit");
                 stmt.addBatch("DROP TABLE artist_credit_name");
@@ -128,14 +127,12 @@
                 stmt.addBatch("DROP TABLE label");
                 stmt.addBatch("DROP TABLE label_alias");
                 stmt.addBatch("DROP TABLE label_alias_type");
-                stmt.addBatch("DROP TABLE label_name");
                 stmt.addBatch("DROP TABLE label_type");
                 stmt.addBatch("DROP TABLE label_tag");
                 stmt.addBatch("DROP TABLE label_ipi");
 
                 stmt.addBatch("DROP TABLE release");
                 stmt.addBatch("DROP TABLE release_meta");
-                stmt.addBatch("DROP TABLE release_name");
                 stmt.addBatch("DROP TABLE release_status");
                 stmt.addBatch("DROP TABLE release_packaging");
                 stmt.addBatch("DROP TABLE release_label");
@@ -156,7 +153,6 @@
 
                 stmt.addBatch("DROP TABLE release_group_tag");
 
-                stmt.addBatch("DROP TABLE track_name");
                 stmt.addBatch("DROP TABLE track");
                 stmt.addBatch("DROP TABLE recording");
                 stmt.addBatch("DROP TABLE recording_tag");
@@ -180,7 +176,6 @@
                 stmt.addBatch("DROP TABLE iswc");
                 stmt.addBatch("DROP TABLE work_alias");
                 stmt.addBatch("DROP TABLE work_alias_type");
-                stmt.addBatch("DROP TABLE work_name");
                 stmt.addBatch("DROP TABLE work_type");
                 stmt.addBatch("DROP TABLE work_tag");
                 stmt.addBatch("DROP TABLE l_artist_work");
@@ -302,8 +297,8 @@
         stmt.addBatch("CREATE TABLE artist (" +
                 "  id serial NOT NULL," +
                 "  gid uuid NOT NULL," +
-                "  name integer NOT NULL," +
-                "  sort_name integer NOT NULL," +
+                "  name character varying(255)," +
+                "  sort_name character varying(255)," +
                 "  begin_date_year integer," +
                 "  begin_date_month integer," +
                 "  begin_date_day integer," +
@@ -323,7 +318,7 @@
 
         stmt.addBatch("CREATE TABLE artist_credit (" +
                 "  id serial NOT NULL," +
-                "  name integer NOT NULL," +
+                "  name character varying(255)," +
                 "  artist_count integer NOT NULL," +
                 "  ref_count integer DEFAULT 0," +
                 "  created timestamp" +
@@ -332,20 +327,20 @@
         stmt.addBatch("CREATE TABLE artist_credit_name (" +
                 "  artist_credit integer NOT NULL," +
                 "  position integer NOT NULL," +
-                "  artist integer NOT NULL," +
-                "  name integer NOT NULL," +
+                "  artist integer not null," +
+                "  name character varying(255)," +
                 "  join_phrase character varying(32)" +
                 ")");
 
         stmt.addBatch("CREATE TABLE artist_alias (" +
                 "  id serial NOT NULL," +
                 "  artist integer NOT NULL," +
-                "  name integer NOT NULL," +
+                "  name character varying(255)," +
                 "  locale text," +
                 "  last_updated timestamp," +
                 "  edits_pending integer NOT NULL DEFAULT 0," +
                 "  type                INTEGER," +
-                "  sort_name           INTEGER NOT NULL," +
+                "  sort_name           character varying(255)," +
                 "  begin_date_year     SMALLINT," +
                 "  begin_date_month    SMALLINT," +
                 "  begin_date_day      SMALLINT," +
@@ -359,11 +354,6 @@
                 " name TEXT" +
                 ")");
 
-        stmt.addBatch("CREATE TABLE artist_name (" +
-                "  id serial NOT NULL," +
-                "  name character varying(255) NOT NULL" +
-                ")");
-
         stmt.addBatch("CREATE TABLE artist_type (" +
                 "  id serial NOT NULL," +
                 "  name character varying(255) NOT NULL" +
@@ -399,8 +389,8 @@
         stmt.addBatch("CREATE TABLE label (" +
                 "  id serial NOT NULL," +
                 "  gid uuid NOT NULL," +
-                "  name integer NOT NULL," +
-                "  sort_name integer NOT NULL," +
+                "  name character varying(255)," +
+                "  sort_name character varying(255)," +
                 "  begin_date_year integer," +
                 "  begin_date_month integer," +
                 "  begin_date_day integer," +
@@ -419,12 +409,12 @@
         stmt.addBatch("CREATE TABLE label_alias (" +
                 "  id serial NOT NULL," +
                 "  label integer NOT NULL," +
-                "  name integer NOT NULL," +
+                "  name character varying(255)," +
                 "  locale text," +
                 "  last_updated timestamp," +
                 "  edits_pending integer NOT NULL DEFAULT 0," +
                 "  type                INTEGER," +
-                "  sort_name           INTEGER NOT NULL," +
+                "  sort_name           character varying(255)," +
                 "  begin_date_year     SMALLINT," +
                 "  begin_date_month    SMALLINT," +
                 "  begin_date_day      SMALLINT," +
@@ -439,11 +429,6 @@
                 " name TEXT" +
                 ")");
 
-        stmt.addBatch("CREATE TABLE label_name (" +
-                "  id serial NOT NULL," +
-                "  name character varying(255) NOT NULL" +
-                ")");
-
         stmt.addBatch("CREATE TABLE label_type (" +
                 "  id serial NOT NULL," +
                 "  name character varying(255) NOT NULL" +
@@ -471,7 +456,7 @@
         stmt.addBatch("CREATE TABLE release (" +
                 "  id serial NOT NULL," +
                 "  gid uuid NOT NULL," +
-                "  name integer NOT NULL," +
+                "  name character varying(255)," +
                 "  artist_credit integer NOT NULL," +
                 "  release_group integer NOT NULL," +
                 "  status integer," +
@@ -484,11 +469,6 @@
                 "  edits_pending integer DEFAULT 0" +
                 ")");
 
-        stmt.addBatch("CREATE TABLE release_name (" +
-                "  id serial NOT NULL," +
-                "  name character varying(255) NOT NULL" +
-                ")");
-
         stmt.addBatch("CREATE TABLE release_status (" +
                 "  id serial NOT NULL," +
                 "  name character varying(255) NOT NULL" +
@@ -595,7 +575,7 @@
         stmt.addBatch("CREATE TABLE release_group (" +
                 "  id serial NOT NULL," +
                 "  gid uuid NOT NULL," +
-                "  name integer NOT NULL," +
+                "  name character varying(255)," +
                 "  artist_credit integer NOT NULL," +
                 "  type integer," +
                 "  comment character varying(255)," +
@@ -629,19 +609,14 @@
 
     protected void setupRecordingTables(Statement stmt) throws Exception {
 
-        stmt.addBatch("CREATE TABLE track_name (" +
-                "  id serial NOT NULL," +
-                "  name character varying NOT NULL" +
-                ")");
-
-        stmt.addBatch("CREATE TABLE track (" +
+       stmt.addBatch("CREATE TABLE track (" +
                 "  id serial," +
                 "  gid uuid," +
                 "  recording integer NOT NULL," +
                 "  medium integer NOT NULL," +
                 "  position integer NOT NULL," +
                 "  number text, " +
-                "  name integer NOT NULL," +
+                "  name character varying(255)," +
                 "  artist_credit integer NOT NULL," +
                 "  length integer," +
                 "  last_updated timestamp," +
@@ -651,7 +626,7 @@
         stmt.addBatch("CREATE TABLE recording (" +
                 "  id serial NOT NULL," +
                 "  gid uuid NOT NULL," +
-                "  name integer NOT NULL," +
+                "  name character varying(255)," +
                 "  artist_credit integer NOT NULL," +
                 "  length integer," +
                 "  comment character varying(255)," +
@@ -773,7 +748,7 @@
         stmt.addBatch("CREATE TABLE work (" +
                 "  id serial NOT NULL," +
                 "  gid uuid NOT NULL," +
-                "  name integer NOT NULL," +
+                "  name character varying(255)," +
                 "  artist_credit integer NOT NULL," +
                 "  type integer," +
                 "  comment character varying(255)," +
@@ -794,8 +769,8 @@
         stmt.addBatch("CREATE TABLE work_alias (" +
                 "  id serial NOT NULL," +
                 "  work integer NOT NULL," +
-                "  name integer NOT NULL," +
-                "  sort_name INTEGER," +
+                "  name character varying(255)," +
+                "  sort_name character varying(255)," +
                 "  type                INTEGER," +
                 "  begin_date_year     SMALLINT," +
                 "  begin_date_month    SMALLINT," +
@@ -812,11 +787,6 @@
                 " name TEXT" +
                 ")");
 
-        stmt.addBatch("CREATE TABLE work_name (" +
-                "  id serial NOT NULL," +
-                "  name character varying NOT NULL" +
-                ")");
-
         stmt.addBatch("CREATE TABLE work_type (" +
                 "  id serial NOT NULL," +
                 "  name character varying(255) NOT NULL" +

Modified: search_server/trunk/index/src/test/java/org/musicbrainz/search/index/AnnotationIndexTest.java
===================================================================
--- search_server/trunk/index/src/test/java/org/musicbrainz/search/index/AnnotationIndexTest.java	2013-09-26 12:49:38 UTC (rev 13706)
+++ search_server/trunk/index/src/test/java/org/musicbrainz/search/index/AnnotationIndexTest.java	2013-09-26 14:45:34 UTC (rev 13707)
@@ -35,9 +35,8 @@
 
         Statement stmt = conn.createStatement();
 
-        stmt.addBatch("INSERT INTO release_name (id, name) VALUES (2, 'Crocodiles (bonus disc)')");
         stmt.addBatch("INSERT INTO release (id, gid, name, artist_credit, release_group) " +
-                "  VALUES (491240, 'c3b8dbc9-c1ff-4743-9015-8d762819134e', 2, 1, 491240)");
+                "  VALUES (491240, 'c3b8dbc9-c1ff-4743-9015-8d762819134e', 'Crocodiles (bonus disc)', 1, 491240)");
         
         stmt.addBatch("INSERT INTO annotation (id, editor, text, changelog, created) " +
         	"  VALUES (1, 1, 'release annotation', 'change', now())");
@@ -54,10 +53,8 @@
 
         Statement stmt = conn.createStatement();
 
-        stmt.addBatch("INSERT INTO release_name (id, name) VALUES (1, 'Crocodiles')");
         stmt.addBatch("INSERT INTO release_group (id, gid, name, artist_credit)" +
-                    "  VALUES (491240, 'efd2ace2-b3b9-305f-8a53-9803595c0e37', 1, 1)");
-         
+                    "  VALUES (491240, 'efd2ace2-b3b9-305f-8a53-9803595c0e37', 'Crocodiles', 1)");
         stmt.addBatch("INSERT INTO annotation (id, editor, text, changelog, created) " +
                     "  VALUES (1, 1, 'release group annotation', 'change', now())");
         stmt.addBatch("INSERT INTO release_group_annotation (release_group, annotation) VALUES (491240, 1)");
@@ -74,9 +71,8 @@
 
         Statement stmt = conn.createStatement();
 
-        stmt.addBatch("INSERT INTO artist_name (id, name) VALUES (1, 'Farming Incident')");
         stmt.addBatch("INSERT INTO artist (id, name, gid, sort_name)" +
-                    "  VALUES (521316, 1, '4302e264-1cf0-4d1f-aca7-2a6f89e34b36', 1)");
+                    "  VALUES (521316, 'Farming Incident', '4302e264-1cf0-4d1f-aca7-2a6f89e34b36', 'Farming Incident')");
 
         stmt.addBatch("INSERT INTO annotation (id, editor, text, changelog, created) " +
                     "  VALUES (1, 1, 'artist annotation', 'change', now())");
@@ -97,10 +93,8 @@
 
         Statement stmt = conn.createStatement();
 
-        stmt.addBatch("INSERT INTO artist_name (id, name) VALUES (1, 'Farming Incident')");
         stmt.addBatch("INSERT INTO artist (id, name, gid, sort_name)" +
-                "  VALUES (521316, 1, '4302e264-1cf0-4d1f-aca7-2a6f89e34b36', 1)");
-
+                "  VALUES (521316, 'Farming Incident', '4302e264-1cf0-4d1f-aca7-2a6f89e34b36', 'Farming Incident')");
         stmt.addBatch("INSERT INTO annotation (id, editor, text, changelog, created) " +
                 "  VALUES (1, 1, '', 'change', now())");
         stmt.addBatch("INSERT INTO artist_annotation (artist, annotation) VALUES (521316, 1)");
@@ -116,9 +110,8 @@
 
         Statement stmt = conn.createStatement();
 
-        stmt.addBatch("INSERT INTO artist_name (id, name) VALUES (1, 'Farming Incident')");
         stmt.addBatch("INSERT INTO artist (id, name, gid, sort_name)" +
-                "  VALUES (521316, 1, '4302e264-1cf0-4d1f-aca7-2a6f89e34b36', 1)");
+                "  VALUES (521316, 'Farming Incident', '4302e264-1cf0-4d1f-aca7-2a6f89e34b36', 'Farming Incident')");
 
         stmt.addBatch("INSERT INTO annotation (id, editor, text, changelog, created) " +
                 "  VALUES (1, 1, null, 'change', now())");
@@ -134,9 +127,8 @@
 
         Statement stmt = conn.createStatement();
 
-        stmt.addBatch("INSERT INTO label_name (id, name) VALUES (1, '4AD')");
         stmt.addBatch("INSERT INTO label (id, gid, name, sort_name) " +
-                "  VALUES (1, 'a539bb1e-f2e1-4b45-9db8-8053841e7503', 1, 1)");
+                "  VALUES (1, 'a539bb1e-f2e1-4b45-9db8-8053841e7503', '4AD', '4AD')");
         
         stmt.addBatch("INSERT INTO annotation (id, editor, text, changelog, created) " +
         	"  VALUES (1, 1, 'label annotation', 'change', now())");
@@ -157,9 +149,8 @@
 
         Statement stmt = conn.createStatement();
 
-        stmt.addBatch("INSERT INTO track_name (id, name) VALUES (1, 'Do It Clean') ");
         stmt.addBatch("INSERT INTO recording (id, gid, name, artist_credit)"
-                       + "VALUES (1, '2f250ed2-6285-40f1-aa2a-14f1c05e9765', 1, 1)");
+                       + "VALUES (1, '2f250ed2-6285-40f1-aa2a-14f1c05e9765', 'Do It Clean', 1)");
         
         stmt.addBatch("INSERT INTO annotation (id, editor, text, changelog, created) " +
         	"  VALUES (1, 1, 'recording annotation', 'change', now())");

Modified: search_server/trunk/index/src/test/java/org/musicbrainz/search/index/ArtistIndexTest.java
===================================================================
--- search_server/trunk/index/src/test/java/org/musicbrainz/search/index/ArtistIndexTest.java	2013-09-26 12:49:38 UTC (rev 13706)
+++ search_server/trunk/index/src/test/java/org/musicbrainz/search/index/ArtistIndexTest.java	2013-09-26 14:45:34 UTC (rev 13707)
@@ -39,9 +39,8 @@
 
         Statement stmt = conn.createStatement();
 
-        stmt.addBatch("INSERT INTO artist_name (id, name) VALUES (1, 'Farming Incident')");
         stmt.addBatch("INSERT INTO artist (id, name, gid, sort_name, begin_date_year, begin_date_month, type, gender, area,begin_area,ended)" +
-            " VALUES (521316, 1, '4302e264-1cf0-4d1f-aca7-2a6f89e34b36', 1, 1999, 4, 2, 1, 1,38,true)");
+            " VALUES (521316, 'Farming Incident', '4302e264-1cf0-4d1f-aca7-2a6f89e34b36', 'incident', 1999, 4, 2, 1, 1,38,true)");
         stmt.addBatch("INSERT INTO artist_ipi (artist,ipi) values(521316,'10001')");
         stmt.addBatch("INSERT INTO area (id, gid, name, sort_name) VALUES (1, '4302e264-1cf0-4d1f-aca7-2a6f89e34b36','Afghanistan','Afghanistan')");
         stmt.addBatch("INSERT INTO iso_3166_1 (area, code) VALUES (1, 'AF')");
@@ -55,28 +54,22 @@
     private void addArtistTwo() throws Exception {
 
         Statement stmt = conn.createStatement();
-        stmt.addBatch("INSERT INTO artist_name (id, name) VALUES (1, 'Echo & The Bunnymen')");
-        stmt.addBatch("INSERT INTO artist_name (id, name) VALUES (2, 'Echo and The Bunnymen')");
-        stmt.addBatch("INSERT INTO artist_name (id, name) VALUES (3, 'Echo & The Bunnyman')");
-        stmt.addBatch("INSERT INTO artist_name (id, name) VALUES (4, 'Echo And The Bunnymen')");
-        stmt.addBatch("INSERT INTO artist_name (id, name) VALUES (5, 'Bunnymen Orchestra')");
-        stmt.addBatch("INSERT INTO artist_name (id, name) VALUES (6, 'Buunymen, Echo And The')");
-
         stmt.addBatch("INSERT INTO artist_alias (id, sort_name, type, artist, name, begin_date_year,begin_date_month,begin_date_day,primary_for_locale ) " +
-                " VALUES (1, 6, 1, 16153, 2,1978,05,01, false)");
+                " VALUES (1, 'Buunymen, Echo And The', 1, 16153, 'Echo and The Bunnymen',1978,05,01, false)");
+        stmt.addBatch("INSERT INTO artist_alias (id, artist, sort_name, name, primary_for_locale, type, end_date_year,end_date_month )" +
+                " VALUES (2, 16153, 'Buunymen, Echo And The', 'Echo & The Bunnyman', null, null, 1984,09)");
+        stmt.addBatch("INSERT INTO artist_alias (id, artist, sort_name, name, primary_for_locale, locale, type ) " +
+                " VALUES (3, 16153, 'Buunymen, Echo And The', 'Echo And The Bunnymen', true, 'en',3)");
 
-        stmt.addBatch("INSERT INTO artist_alias (id, artist, sort_name, name, primary_for_locale, type, end_date_year,end_date_month ) VALUES (2, 16153, 6, 3, null, null, 1984,09)");
-        stmt.addBatch("INSERT INTO artist_alias (id, artist, sort_name, name, primary_for_locale, locale, type ) VALUES (3, 16153, 6, 4, true, 'en',3)");
-
         stmt.addBatch("INSERT INTO artist_credit_name (artist_credit, position, artist, name) " +
-                " VALUES (1, 0, 16153, 5)");
+                " VALUES (1, 0, 16153, 'Bunnymen Orchestra')");
 
         //This is same as alias, so should be ignored
         stmt.addBatch("INSERT INTO artist_credit_name (artist_credit, position, artist, name) " +
-                " VALUES (1, 0, 16153, 3)");
+                " VALUES (1, 0, 16153, 'Echo & The Bunnyman')");
 
         stmt.addBatch("INSERT INTO artist (id, name, gid, sort_name, comment, begin_date_year, end_date_year, type)" +
-                   " VALUES (16153, 1, 'ccd4879c-5e88-4385-b131-bf65296bf245', 1, 'a comment', 1978, 1995, 2)");
+                   " VALUES (16153, 'Echo & The Bunnymen', 'ccd4879c-5e88-4385-b131-bf65296bf245', 1, 'a comment', 1978, 1995, 2)");
 
 
         stmt.executeBatch();
@@ -86,13 +79,9 @@
     private void addArtistThree() throws Exception {
 
         Statement stmt = conn.createStatement();
-        stmt.addBatch("INSERT INTO artist_name (id, name) VALUES (1, 'Siobhan Lynch')");
-        stmt.addBatch("INSERT INTO artist_name (id, name) VALUES (2, 'Lynch, Siobhan')");
-
         stmt.addBatch("INSERT INTO artist (id, name, gid, sort_name,type)" +
-            " VALUES (76834, 1, 'ae8707b6-684c-4d4a-95c5-d117970a6dfe', 2, 1)");
+            " VALUES (76834, 'Siobhan Lynch', 'ae8707b6-684c-4d4a-95c5-d117970a6dfe', 'Lynch, Siobhan', 1)");
 
-
         stmt.addBatch("INSERT INTO tag (id, name, ref_count) VALUES (1, 'Goth', 2)");
         stmt.addBatch("INSERT INTO artist_tag (artist, tag, count) VALUES (76834, 1, 10)");
         stmt.executeBatch();
@@ -102,12 +91,8 @@
     private void addArtistFour() throws Exception {
 
         Statement stmt = conn.createStatement();
-        stmt.addBatch("INSERT INTO artist_name (id, name) VALUES (1, 'Siobhan Lynch')");
-        stmt.addBatch("INSERT INTO artist_name (id, name) VALUES (2, 'Lynch, Siobhan')");
-
         stmt.addBatch("INSERT INTO artist (id, name, gid, sort_name, type)" +
-            " VALUES (76834, 1, 'ae8707b6-684c-4d4a-95c5-d117970a6dfe', 2, 1)");
-
+            " VALUES (76834, 'Siobhan Lynch', 'ae8707b6-684c-4d4a-95c5-d117970a6dfe', 'Lynch, Siobhan', 1)");
         stmt.addBatch("INSERT INTO tag (id, name, ref_count) VALUES (1, 'Goth', 2)");
         stmt.addBatch("INSERT INTO artist_tag (artist, tag, count) VALUES (76834, 1, 10)");
         stmt.executeBatch();
@@ -133,8 +118,8 @@
             checkTerm(ir, ArtistIndexField.ARTIST, "farming");
             checkTermX(ir, ArtistIndexField.ARTIST, "incident",1);
             checkTerm(ir, ArtistIndexField.ARTIST_ID, "4302e264-1cf0-4d1f-aca7-2a6f89e34b36");
-            checkTerm(ir, ArtistIndexField.SORTNAME, "farming");
-            checkTermX(ir, ArtistIndexField.SORTNAME, "incident", 1);
+            checkTerm(ir, ArtistIndexField.SORTNAME, "incident");
+//            checkTermX(ir, ArtistIndexField.SORTNAME, "incident", 1);
             checkTerm(ir, ArtistIndexField.BEGIN, "1999-04");
             checkTerm(ir, ArtistIndexField.TYPE, "group");
         }

Modified: search_server/trunk/index/src/test/java/org/musicbrainz/search/index/LabelIndexTest.java
===================================================================
--- search_server/trunk/index/src/test/java/org/musicbrainz/search/index/LabelIndexTest.java	2013-09-26 12:49:38 UTC (rev 13706)
+++ search_server/trunk/index/src/test/java/org/musicbrainz/search/index/LabelIndexTest.java	2013-09-26 14:45:34 UTC (rev 13707)
@@ -43,14 +43,10 @@
     private void addLabelOne() throws Exception {
 
         Statement stmt = conn.createStatement();
-
-	    stmt.addBatch("INSERT INTO label_name (id, name) VALUES (1, '4AD')");
-	    stmt.addBatch("INSERT INTO label_name (id, name) VALUES (2, '4AD US')");
-		
         stmt.addBatch("INSERT INTO label (id, gid, name, sort_name, type, label_code, begin_date_year, ended) " +
-					"VALUES (1, 'a539bb1e-f2e1-4b45-9db8-8053841e7503', 1, 1, 4, 5807, 1979, true)");
+					"VALUES (1, 'a539bb1e-f2e1-4b45-9db8-8053841e7503', '4AD', '4AD US', 4, 5807, 1979, true)");
         stmt.addBatch("INSERT INTO label_ipi (label, ipi) values(1,'1001')");
-        stmt.addBatch("INSERT INTO label_alias (label, name, sort_name) VALUES (1, 2, 2)");
+        stmt.addBatch("INSERT INTO label_alias (label, name, sort_name) VALUES (1, '4AD', '4AD US')");
 
         stmt.executeBatch();
         stmt.close();
@@ -68,11 +64,9 @@
 
         stmt.addBatch("INSERT INTO area (id, gid, name, sort_name) VALUES (38, 'b8caa692-704d-412b-a410-4fbcf5b9c796','Canada','Canada')");
         stmt.addBatch("INSERT INTO iso_3166_1 (area, code) VALUES (38, 'CA')");
-	    stmt.addBatch("INSERT INTO label_name (id, name) VALUES (3, 'MusicBrainz Data Testing Label')");
-	    stmt.addBatch("INSERT INTO label_name (id, name) VALUES (4, 'Data Testing Label, MusicBrainz')");
-		stmt.addBatch("INSERT INTO label(id, gid, name, sort_name, type, label_code, area, comment, " +
+	    stmt.addBatch("INSERT INTO label(id, gid, name, sort_name, type, label_code, area, comment, " +
 					"	begin_date_year, begin_date_month, begin_date_day, end_date_year, end_date_month,ended) " +
-					"VALUES (2, 'd8caa692-704d-412b-a410-4fbcf5b9c796', 3, 4, 1, 0099998, 38, 'DO NOT EDIT THIS LABEL', " +
+					"VALUES (2, 'd8caa692-704d-412b-a410-4fbcf5b9c796', 'MusicBrainz Data Testing Label', 'Data Testing Label, MusicBrainz', 1, 0099998, 38, 'DO NOT EDIT THIS LABEL', " +
 					"	2009, 1, 1, 2009, 4,false)");
 
         stmt.executeBatch();
@@ -90,11 +84,8 @@
 
         stmt.addBatch("INSERT INTO area (id, name) VALUES (1, 'Afghanistan')");
         stmt.addBatch("INSERT INTO iso_3166_1 (area, code) VALUES (1, 'AF')");
-        stmt.addBatch("INSERT INTO label_name (id, name) VALUES (1, '4AD')");
-		stmt.addBatch("INSERT INTO label_name (id, name) VALUES (2, '4AD US')");
-		
         stmt.addBatch("INSERT INTO label (id, gid, name, sort_name, area, ended)" +
-					"VALUES (3, 'a539bb1e-f2e1-4b45-9db8-8053841e7503', 1, 1, 1, true)");
+					"VALUES (3, 'a539bb1e-f2e1-4b45-9db8-8053841e7503', '4AD', '4AD US', 1, true)");
         stmt.addBatch("INSERT INTO label_alias (label, name,sort_name) VALUES (3, 2, 2)");
 
         stmt.addBatch("INSERT INTO tag (id, name, ref_count) VALUES (1, 'Goth', 2);");
@@ -452,10 +443,9 @@
             assertEquals("a539bb1e-f2e1-4b45-9db8-8053841e7503", label.getId());
             assertEquals("4AD", label.getName());
             assertNull(label.getCountry());
-            assertEquals("4AD", label.getSortName());
+            assertEquals("4AD US", label.getSortName());
             assertNull(label.getDisambiguation());
             assertEquals("Original Production",label.getType());
-            assertEquals("4AD",label.getSortName());
         }
         ir.close();
     }

Modified: search_server/trunk/index/src/test/java/org/musicbrainz/search/index/RecordingIndexTest.java
===================================================================
--- search_server/trunk/index/src/test/java/org/musicbrainz/search/index/RecordingIndexTest.java	2013-09-26 12:49:38 UTC (rev 13706)
+++ search_server/trunk/index/src/test/java/org/musicbrainz/search/index/RecordingIndexTest.java	2013-09-26 14:45:34 UTC (rev 13707)
@@ -43,27 +43,21 @@
 
         Statement stmt = conn.createStatement();
 
-        stmt.addBatch("INSERT INTO artist_name (id, name) VALUES (1, 'Echo & The Bunnymen')");
-        stmt.addBatch("INSERT INTO artist_name (id, name) VALUES (2, 'Echo and The Bunnymen')");
-
         stmt.addBatch("INSERT INTO artist (id, gid, name, sort_name, comment)" +
-                " VALUES (16153, 'ccd4879c-5e88-4385-b131-bf65296bf245', 1, 2,'')");
-        stmt.addBatch("INSERT INTO artist_credit (id, name, artist_count, ref_count) VALUES (1, 1, 1, 1)");
+                " VALUES (16153, 'ccd4879c-5e88-4385-b131-bf65296bf245', 'Echo & The Bunnymen', 'Echo and The Bunnymen','')");
+        stmt.addBatch("INSERT INTO artist_credit (id, name, artist_count, ref_count) VALUES (1,  'Echo & The Bunnymen', 1, 1)");
         stmt.addBatch("INSERT INTO artist_credit_name (artist_credit, position, artist, name, join_phrase) " +
-                " VALUES (1, 0, 16153, 1, '')");
+                " VALUES (1, 0, 16153, 'Echo & The Bunnymen', '')");
 
-        stmt.addBatch("INSERT INTO release_name (id, name) VALUES (1, 'Crocodiles')");
-        stmt.addBatch("INSERT INTO release_name (id, name) VALUES (2, 'Crocodiles (bonus disc)')");
         stmt.addBatch("INSERT INTO release_group (id, gid, name, artist_credit, type)" +
-                " VALUES (491240, 'efd2ace2-b3b9-305f-8a53-9803595c0e37', 1, 1, 1)");
+                " VALUES (491240, 'efd2ace2-b3b9-305f-8a53-9803595c0e37', 'Crocodiles', 1, 1)");
 
         stmt.addBatch("INSERT INTO release_group_secondary_type_join (release_group, secondary_type) VALUES (491240,1)");
         stmt.addBatch("INSERT INTO release_group_secondary_type_join (release_group, secondary_type) VALUES (491240,2)");
 
-
         stmt.addBatch("INSERT INTO release (id, gid, name, artist_credit, release_group, status, packaging, " +
                 "  language, script) " +
-                " VALUES (491240, 'c3b8dbc9-c1ff-4743-9015-8d762819134e', 2, 1, 491240, 1, 1, 1, 1)");
+                " VALUES (491240, 'c3b8dbc9-c1ff-4743-9015-8d762819134e', 'Crocodiles (bonus disc)', 1, 491240, 1, 1, 1, 1)");
 
         stmt.addBatch("INSERT INTO release_country (release, country, date_year, date_month, date_day) values (491240, 221, 1970,1,1)");
         stmt.addBatch("INSERT INTO area (id, gid, name, sort_name) VALUES (221, 'c3b8dbc9-c1ff-4743-9015-8d762819134g','United Kingdom','Kingdom of UK')");
@@ -82,13 +76,10 @@
         stmt.addBatch("INSERT INTO medium (id, track_count, release, position, format) VALUES (1, 2, 491240, 1, 7)");
 
         stmt.addBatch("INSERT INTO track (id, gid, recording, medium, position, number, name, artist_credit, length) "
-                + " VALUES (1, 'c3b8dbc9-c1ff-4743-9015-8d762819134e', 1, 1, 4, 'A4', 2, 1, 33100)");
+                + " VALUES (1, 'c3b8dbc9-c1ff-4743-9015-8d762819134e', 1, 1, 4, 'A4', 'Do It Cleans', 1, 33100)");
         stmt.addBatch("INSERT INTO recording (id, gid, name, artist_credit, length, comment)"
-                + " VALUES (1, '2f250ed2-6285-40f1-aa2a-14f1c05e9765', 1, 1, 33000, 'demo')");
+                + " VALUES (1, '2f250ed2-6285-40f1-aa2a-14f1c05e9765', 'Do It Clean', 1, 33000, 'demo')");
 
-        stmt.addBatch("INSERT INTO track_name (id, name) VALUES (1, 'Do It Clean')");
-        stmt.addBatch("INSERT INTO track_name (id, name) VALUES (2, 'Do It Cleans')");
-
         stmt.addBatch("INSERT INTO isrc (id, recording, isrc) VALUES (1, 1, 'FRAAA9000038')");
         stmt.addBatch("INSERT INTO isrc (id, recording, isrc) VALUES (2, 1, 'FRAAA9100082')");
 
@@ -111,37 +102,29 @@
 
         Statement stmt = conn.createStatement();
 
-        stmt.addBatch("INSERT INTO artist_name (id, name) VALUES (1, 'Echo & The Bunnymen')");
-
         stmt.addBatch("INSERT INTO artist (id, gid, name, sort_name, comment)" +
-                " VALUES (16153, 'ccd4879c-5e88-4385-b131-bf65296bf245', 1, 1, 'a comment')");
-        stmt.addBatch("INSERT INTO artist_credit (id, name, artist_count, ref_count) VALUES (1, 1, 1, 1)");
+                " VALUES (16153, 'ccd4879c-5e88-4385-b131-bf65296bf245', 'Echo & The Bunnymen', 1, 'a comment')");
+        stmt.addBatch("INSERT INTO artist_credit (id, name, artist_count, ref_count) VALUES (1, 'Echo & The Bunnymen', 1, 1)");
         stmt.addBatch("INSERT INTO artist_credit_name (artist_credit, position, artist, name, join_phrase) " +
-                " VALUES (1, 0, 16153, 1,'')");
+                " VALUES (1, 0, 16153, 'Echo & The Bunnymen','')");
 
-        stmt.addBatch("INSERT INTO artist_name (id, name) VALUES (2, 'Pixies')");
-
         stmt.addBatch("INSERT INTO artist (id, gid, name, sort_name, comment)" +
-                " VALUES (2, 'ddd4879c-5e88-4385-b131-bf65296bf245', 2, 2, 'a comment')");
-        stmt.addBatch("INSERT INTO artist_credit (id, name, artist_count, ref_count) VALUES (2, 2, 1, 1)");
+                " VALUES (2, 'ddd4879c-5e88-4385-b131-bf65296bf245', 'Pixies','Pixies', 'a comment')");
+        stmt.addBatch("INSERT INTO artist_credit (id, name, artist_count, ref_count) VALUES (2, 'Pixies', 1, 1)");
         stmt.addBatch("INSERT INTO artist_credit_name (artist_credit, position, artist, name) " +
-                " VALUES (2, 0, 2, 1)");
+                " VALUES (2, 0, 2, 'Pixies')");
 
-
-        stmt.addBatch("INSERT INTO release_name (id, name) VALUES (1, 'Crocodiles')");
-        stmt.addBatch("INSERT INTO release_name (id, name) VALUES (2, 'Crocodiles (bonus disc)')");
         stmt.addBatch("INSERT INTO release_group (id, gid, name, artist_credit)" +
-                " VALUES (491240, 'efd2ace2-b3b9-305f-8a53-9803595c0e37', 1, 1)");
+                " VALUES (491240, 'efd2ace2-b3b9-305f-8a53-9803595c0e37',  'Crocodiles', 1)");
 
         stmt.addBatch("INSERT INTO release (id, gid, name, artist_credit, release_group, packaging, " +
                 "  language, script) " +
-                " VALUES (491240, 'c3b8dbc9-c1ff-4743-9015-8d762819134e', 2, 1, 491240, 1, 1, 1)");
+                " VALUES (491240, 'c3b8dbc9-c1ff-4743-9015-8d762819134e', 'Crocodiles (bonus disc)', 1, 491240, 1, 1, 1)");
         stmt.addBatch("INSERT INTO medium (id, track_count, release, position, format) VALUES (1, 2, 491240, 1, 7)");
         stmt.addBatch("INSERT INTO track (id, gid, recording, medium, position, name, artist_credit, length) "
-                + " VALUES (1, 'c3b8dbc9-c1ff-4743-9015-8d762819134e', 1, 1, 4, 1, 2, 33100)");
+                + " VALUES (1, 'c3b8dbc9-c1ff-4743-9015-8d762819134e', 1, 1, 4, 'Do It Clean', 2, 33100)");
         stmt.addBatch("INSERT INTO recording (id, gid, name, artist_credit, length)"
-                + " VALUES (1, '2f250ed2-6285-40f1-aa2a-14f1c05e9765', 1, 1, 33000)");
-        stmt.addBatch("INSERT INTO track_name (id, name) VALUES (1, 'Do It Clean')");
+                + " VALUES (1, '2f250ed2-6285-40f1-aa2a-14f1c05e9765', 'Do It Clean', 1, 33000)");
         stmt.addBatch("INSERT INTO tag (id, name, ref_count) VALUES (1, 'punk', 2)");
         stmt.addBatch("INSERT INTO recording_tag (recording, tag, count) VALUES (1, 1, 10)");
 
@@ -158,46 +141,34 @@
 
         Statement stmt = conn.createStatement();
 
-        stmt.addBatch("INSERT INTO artist_name (id, name) VALUES (1, 'Echo & The Bunnymen')");
-        stmt.addBatch("INSERT INTO artist_name (id, name) VALUES (2, 'Echo and The Bunnymen')");
-
         stmt.addBatch("INSERT INTO artist (id, gid, name, sort_name, comment)" +
-                " VALUES (16153, 'ccd4879c-5e88-4385-b131-bf65296bf245', 1, 2,'')");
-        stmt.addBatch("INSERT INTO artist_credit (id, name, artist_count, ref_count) VALUES (1, 1, 1, 1)");
+                " VALUES (16153, 'ccd4879c-5e88-4385-b131-bf65296bf245', 'Echo & The Bunnymen', 'Echo and The Bunnymen','')");
+        stmt.addBatch("INSERT INTO artist_credit (id, name, artist_count, ref_count) VALUES (1, 'Echo & The Bunnymen', 1, 1)");
         stmt.addBatch("INSERT INTO artist_credit_name (artist_credit, position, artist, name, join_phrase) " +
-                " VALUES (1, 0, 16153, 1, '')");
+                " VALUES (1, 0, 16153, 'Echo & The Bunnymen', '')");
 
-        stmt.addBatch("INSERT INTO release_name (id, name) VALUES (1, 'Crocodiles')");
-        stmt.addBatch("INSERT INTO release_name (id, name) VALUES (2, 'Crocodiles (bonus disc)')");
         stmt.addBatch("INSERT INTO release_group (id, gid, name, artist_credit, type)" +
-                " VALUES (491240, 'efd2ace2-b3b9-305f-8a53-9803595c0e37', 1, 1, 1)");
+                " VALUES (491240, 'efd2ace2-b3b9-305f-8a53-9803595c0e37',  'Crocodiles', 1, 1)");
         stmt.addBatch("INSERT INTO release_group (id, gid, name, artist_credit, type)" +
-                " VALUES (491243, 'efd2ace2-b3b9-305f-8a53-9803595c0e67', 2, 1, 2)");
+                " VALUES (491243, 'efd2ace2-b3b9-305f-8a53-9803595c0e67', 'Crocodiles (bonus disc)', 1, 2)");
         stmt.addBatch("INSERT INTO release (id, gid, name, artist_credit, release_group, status, packaging, " +
                 "  language, script) " +
-                " VALUES (491240, 'c3b8dbc9-c1ff-4743-9015-8d762819134e', 2, 1, 491240, 1, 1, 1, 1)");
+                " VALUES (491240, 'c3b8dbc9-c1ff-4743-9015-8d762819134e', 'Crocodiles (bonus disc)', 1, 491240, 1, 1, 1, 1)");
         stmt.addBatch("INSERT INTO medium (id, track_count, release, position, format, name) VALUES (1, 2, 491240, 1, 7, null)");
         stmt.addBatch("INSERT INTO track (id, gid, recording, medium, position, name, artist_credit, length) "
-                + " VALUES (1, 'c3b8dbc9-c1ff-4743-9015-8d762819134e', 1, 1, 7, 2, 1, 33100)");
+                + " VALUES (1, 'c3b8dbc9-c1ff-4743-9015-8d762819134e', 1, 1, 7, 'Do It Cleans', 1, 33100)");
         stmt.addBatch("INSERT INTO recording (id, gid, name, artist_credit, length)"
-                + " VALUES (1, '2f250ed2-6285-40f1-aa2a-14f1c05e9765', 1, 1, 33000)");
+                + " VALUES (1, '2f250ed2-6285-40f1-aa2a-14f1c05e9765', 'Do It Cleans', 1, 33000)");
 
-
-
         stmt.addBatch("INSERT INTO release (id, gid, name, artist_credit, release_group, status, " +
                 "  language, script) " +
-                " VALUES (491241, 'c3b8dbc9-c1ff-4743-9015-8d762819134f', 1, 1, 491243, 2, 1, 1)");
+                " VALUES (491241, 'c3b8dbc9-c1ff-4743-9015-8d762819134f', 'Crocodiles', 1, 491243, 2, 1, 1)");
 
 
-
         stmt.addBatch("INSERT INTO medium (id, track_count, release, position, format) VALUES (2, 2, 491241, 1, 7)");
 
         stmt.addBatch("INSERT INTO track (id, gid, recording, medium, position, name, artist_credit, length) "
                 + " VALUES (2, 'd3b8dbc9-c1ff-4743-9015-8d762819134e', 1, 2, 4, 2, 1, 33100)");
-
-        stmt.addBatch("INSERT INTO track_name (id, name) VALUES (1, 'Do It Clean')");
-        stmt.addBatch("INSERT INTO track_name (id, name) VALUES (2, 'Do It Cleans')");
-
         stmt.addBatch("INSERT INTO isrc (id, recording, isrc) VALUES (1, 1, 'FRAAA9000038')");
         stmt.addBatch("INSERT INTO isrc (id, recording, isrc) VALUES (2, 1, 'FRAAA9100082')");
 
@@ -216,18 +187,14 @@
 
         Statement stmt = conn.createStatement();
 
-        stmt.addBatch("INSERT INTO artist_name (id, name) VALUES (1, 'Echo & The Bunnymen')");
-        stmt.addBatch("INSERT INTO artist_name (id, name) VALUES (2, 'Echo and The Bunnymen')");
-
         stmt.addBatch("INSERT INTO artist (id, gid, name, sort_name, comment)" +
-                " VALUES (16153, 'ccd4879c-5e88-4385-b131-bf65296bf245', 1, 2,'')");
-        stmt.addBatch("INSERT INTO artist_credit (id, name, artist_count, ref_count) VALUES (1, 1, 1, 1)");
+                " VALUES (16153, 'ccd4879c-5e88-4385-b131-bf65296bf245', 'Echo & The Bunnymen', 'Echo and The Bunnymen','')");
+        stmt.addBatch("INSERT INTO artist_credit (id, name, artist_count, ref_count) VALUES (1, 'Echo and The Bunnymen', 1, 1)");
         stmt.addBatch("INSERT INTO artist_credit_name (artist_credit, position, artist, name, join_phrase) " +
-                " VALUES (1, 0, 16153, 1, '')");
+                " VALUES (1, 0, 16153, 'Echo and The Bunnymen', '')");
 
         stmt.addBatch("INSERT INTO recording (id, gid, name, artist_credit, length)"
-                + " VALUES (1, '2f250ed2-6285-40f1-aa2a-14f1c05e9765', 1, 1, 33000)");
-        stmt.addBatch("INSERT INTO track_name (id, name) VALUES (1, 'Do It Clean')");
+                + " VALUES (1, '2f250ed2-6285-40f1-aa2a-14f1c05e9765', 'Do It Clean', 1, 33000)");
 
         stmt.addBatch("INSERT INTO puid (id, puid) VALUES (1, 'efd2ace2-b3b9-305f-8a53-9803595c0e38')");
         stmt.addBatch("INSERT INTO recording_puid (id, puid, recording) VALUES (1, 1, 1)");

Modified: search_server/trunk/index/src/test/java/org/musicbrainz/search/index/ReleaseGroupIndexTest.java
===================================================================
--- search_server/trunk/index/src/test/java/org/musicbrainz/search/index/ReleaseGroupIndexTest.java	2013-09-26 12:49:38 UTC (rev 13706)
+++ search_server/trunk/index/src/test/java/org/musicbrainz/search/index/ReleaseGroupIndexTest.java	2013-09-26 14:45:34 UTC (rev 13707)
@@ -53,23 +53,17 @@
     private void addReleaseGroupOne() throws Exception {
 
         Statement stmt = conn.createStatement();
-
-        stmt.addBatch("INSERT INTO artist_name (id, name) VALUES (1, 'Echo & The Bunnymen')");
-        stmt.addBatch("INSERT INTO artist_name (id, name) VALUES (2, 'Echo and The Bunnymen')");
-
         stmt.addBatch("INSERT INTO artist (id, gid, name, sort_name, comment, begin_date_year, end_date_year, type)" +
-                " VALUES (16153, 'ccd4879c-5e88-4385-b131-bf65296bf245', 1, 2, 'a comment', 1978, 1995, 2)");
-        stmt.addBatch("INSERT INTO artist_credit (id, name, artist_count, ref_count) VALUES (1, 1, 1, 1)");
+                " VALUES (16153, 'ccd4879c-5e88-4385-b131-bf65296bf245', 'Echo & The Bunnymen', 'Echo and The Bunnymen', 'a comment', 1978, 1995, 2)");
+        stmt.addBatch("INSERT INTO artist_credit (id, name, artist_count, ref_count) VALUES (1, 'Echo & The Bunnymen', 1, 1)");
         stmt.addBatch("INSERT INTO artist_credit_name (artist_credit, position, artist, name, join_phrase) " +
                 " VALUES (1, 0, 16153, 1,'')");
 
-        stmt.addBatch("INSERT INTO release_name (id, name) VALUES (1, 'Crocodiles')");
-        stmt.addBatch("INSERT INTO release_name (id, name) VALUES (2, 'Crocodiles (bonus disc)')");
         stmt.addBatch("INSERT INTO release_group (id, gid, name, artist_credit, type, comment)" +
-                " VALUES (491240, 'efd2ace2-b3b9-305f-8a53-9803595c0e37', 1, 1, 1, 'demo')");
+                " VALUES (491240, 'efd2ace2-b3b9-305f-8a53-9803595c0e37', 'Crocodiles', 1, 1, 'demo')");
 
         stmt.addBatch("INSERT INTO release (id, gid, name, artist_credit, release_group) " +
-                " VALUES (491240, 'c3b8dbc9-c1ff-4743-9015-8d762819134e', 2, 1, 491240)");
+                " VALUES (491240, 'c3b8dbc9-c1ff-4743-9015-8d762819134e', 'Crocodiles (bonus disc)', 1, 491240)");
 
         stmt.executeBatch();
         stmt.close();
@@ -84,24 +78,18 @@
 
         Statement stmt = conn.createStatement();
 
-        stmt.addBatch("INSERT INTO artist_name (id, name) VALUES (1, 'Echo & The Bunnymen')");
-        stmt.addBatch("INSERT INTO artist_name (id, name) VALUES (2, 'aliastest')");
-
         stmt.addBatch("INSERT INTO artist (id, gid, name, sort_name, comment)" +
-                " VALUES (16153, 'ccd4879c-5e88-4385-b131-bf65296bf245', 1, 1, 'a comment')");
-        stmt.addBatch("INSERT INTO artist_alias(id, artist, name, sort_name, locale, edits_pending, last_updated) VALUES (1, 16153, 2,2, 'en',1,null)");
+                " VALUES (16153, 'ccd4879c-5e88-4385-b131-bf65296bf245', 'Echo & The Bunnymen', 'Echo & The Bunnymen', 'a comment')");
+        stmt.addBatch("INSERT INTO artist_alias(id, artist, name, sort_name, locale, edits_pending, last_updated) VALUES (1, 16153, 'aliastest','aliastest', 'en',1,null)");
         stmt.addBatch("INSERT INTO artist_credit (id, name, artist_count, ref_count) VALUES (1, 1, 1, 1)");
         stmt.addBatch("INSERT INTO artist_credit_name (artist_credit, position, artist, name, join_phrase) " +
                 " VALUES (1, 0, 16153, 1, '')");
 
-        stmt.addBatch("INSERT INTO release_name (id, name) VALUES (1, 'Crocodiles')");
-        stmt.addBatch("INSERT INTO release_name (id, name) VALUES (2, 'Crocodiles (bonus disc)')");
-
         stmt.addBatch("INSERT INTO release_group (id, gid, name, artist_credit)" +
-                " VALUES (491240, 'efd2ace2-b3b9-305f-8a53-9803595c0e37', 1, 1)");
+                " VALUES (491240, 'efd2ace2-b3b9-305f-8a53-9803595c0e37', 'Crocodiles', 1)");
 
         stmt.addBatch("INSERT INTO release (id, gid, name, artist_credit, release_group) " +
-                " VALUES (491240, 'c3b8dbc9-c1ff-4743-9015-8d762819134e', 2, 1, 491240)");
+                " VALUES (491240, 'c3b8dbc9-c1ff-4743-9015-8d762819134e', 'Crocodiles (bonus disc)', 1, 491240)");
 
         stmt.executeBatch();
         stmt.close();
@@ -116,27 +104,20 @@
 
         Statement stmt = conn.createStatement();
 
-
-        stmt.addBatch("INSERT INTO artist_name (id, name) VALUES (1, 'Echo & The Bunnymen')");
-
         stmt.addBatch("INSERT INTO artist (id, gid, name, sort_name, comment)" +
-                " VALUES (16153, 'ccd4879c-5e88-4385-b131-bf65296bf245', 1, 1, 'a comment')");
-        stmt.addBatch("INSERT INTO artist_credit (id, name, artist_count, ref_count) VALUES (1, 1, 1, 1)");
+                " VALUES (16153, 'ccd4879c-5e88-4385-b131-bf65296bf245', 'Echo & The Bunnymen', 'Echo & The Bunnymen', 'a comment')");
+        stmt.addBatch("INSERT INTO artist_credit (id, name, artist_count, ref_count) VALUES (1, 'Echo & The Bunnymen', 1, 1)");
         stmt.addBatch("INSERT INTO artist_credit_name (artist_credit, position, artist,name, join_phrase) " +
-                " VALUES (1, 0, 16153, 1, '')");
-        
-        stmt.addBatch("INSERT INTO release_name (id, name) VALUES (1, 'Crocodiles')");
-        stmt.addBatch("INSERT INTO release_name (id, name) VALUES (2, 'Crocodiles (Bonus disc)')");
-        stmt.addBatch("INSERT INTO release_name (id, name) VALUES (3, 'Crocodiles (Special disc)')");
+                " VALUES (1, 0, 16153, 'Echo & The Bunnymen', '')");
 
         stmt.addBatch("INSERT INTO release_group (id, gid, name, artist_credit, type)" +
-                " VALUES (491240, 'efd2ace2-b3b9-305f-8a53-9803595c0e37', 1, 1, 2)");
+                " VALUES (491240, 'efd2ace2-b3b9-305f-8a53-9803595c0e37', 'Crocodiles', 1, 2)");
 
         stmt.addBatch("INSERT INTO release (id, gid, name, artist_credit, release_group) " +
-                " VALUES (491240, 'c3b8dbc9-c1ff-4743-9015-8d762819134e', 2, 1, 491240)");
+                " VALUES (491240, 'c3b8dbc9-c1ff-4743-9015-8d762819134e', 'Crocodiles (Bonus disc)', 1, 491240)");
 
         stmt.addBatch("INSERT INTO release (id, gid, name, artist_credit, release_group) " +
-                " VALUES (491241, 'c3b8dbc9-c1ff-4743-9015-8d762819134e', 3, 1, 491240)");
+                " VALUES (491241, 'c3b8dbc9-c1ff-4743-9015-8d762819134e', 'Crocodiles (Special disc)', 1, 491240)");
 
         stmt.executeBatch();
         stmt.close();
@@ -149,33 +130,25 @@
 
         Statement stmt = conn.createStatement();
 
-        stmt.addBatch("INSERT INTO artist_name (id, name) VALUES (1, 'Erich Kunzel')");
-        stmt.addBatch("INSERT INTO artist_name (id, name) VALUES (2, 'Kunzel, Eric')");
-        stmt.addBatch("INSERT INTO artist_name (id, name) VALUES (3, 'The Cincinnati Pops Orchestra')");
-        stmt.addBatch("INSERT INTO artist_name (id, name) VALUES (4, 'Cincinnati Pops Orchestra, The')");
-        stmt.addBatch("INSERT INTO artist_name (id, name) VALUES (5, 'Cincinnati Pops')");
-        stmt.addBatch("INSERT INTO artist_name (id, name) VALUES (6, 'Erich Kunzel and Kunzel, Eric')");
-
         stmt.addBatch("INSERT INTO artist (id, gid, name, sort_name, comment)" +
-                " VALUES (1, '99845d0c-f239-4051-a6b1-4b5e9f7ede0b', 1, 2, 'a comment')");
+                " VALUES (1, '99845d0c-f239-4051-a6b1-4b5e9f7ede0b', 'Erich Kunzel', 'Kunzel, Eric', 'a comment')");
         stmt.addBatch("INSERT INTO artist (id, gid, name, sort_name, comment)" +
-                " VALUES (2, 'd8fbd94c-cd06-4e8b-a559-761ad969d07e', 3, 4, 'a comment')");
+                " VALUES (2, 'd8fbd94c-cd06-4e8b-a559-761ad969d07e', 'The Cincinnati Pops Orchestra', 'Cincinnati Pops Orchestra, The', 'a comment')");
 
-        stmt.addBatch("INSERT INTO artist_credit (id, name, artist_count, ref_count) VALUES (1, 6, 1, 1)");
+        stmt.addBatch("INSERT INTO artist_credit (id, name, artist_count, ref_count) VALUES (1, 'Erich Kunzel and Kunzel, Eric', 1, 1)");
         stmt.addBatch("INSERT INTO artist_credit_name (artist_credit, position, artist, name, join_phrase)" +
-                " VALUES (1, 0, 1, 1, ' and ')");
+                " VALUES (1, 0, 1, 'Erich Kunzel', ' and ')");
         stmt.addBatch("INSERT INTO artist_credit_name (artist_credit, position, artist, name, join_phrase)" +
-                " VALUES (1, 1, 2, 5,'')");
+                " VALUES (1, 1, 2, 'Cincinnati Pops','')");
         
-        stmt.addBatch("INSERT INTO release_name (id, name) VALUES (1, 'Epics')");
         stmt.addBatch("INSERT INTO release_group (id, gid, name, artist_credit, type)" +
-                "    VALUES (1, 'efd2ace2-b3b9-305f-8a53-9803595c0e37', 1, 1, 1)");
+                "    VALUES (1, 'efd2ace2-b3b9-305f-8a53-9803595c0e37', 'Epics', 1, 1)");
 
         stmt.addBatch("INSERT INTO release_group_secondary_type_join (release_group, secondary_type) VALUES (1,1)");
         stmt.addBatch("INSERT INTO release_group_secondary_type_join (release_group, secondary_type) VALUES (1,2)");
 
         stmt.addBatch("INSERT INTO release (id, gid, name, artist_credit, release_group, status) " +
-                " VALUES (1, 'c3b8dbc9-c1ff-4743-9015-8d762819134e', 1, 1, 1, 1)");
+                " VALUES (1, 'c3b8dbc9-c1ff-4743-9015-8d762819134e', 'Erich Kunzel', 1, 1, 1)");
 
         stmt.addBatch("INSERT INTO tag (id, name, ref_count) VALUES (1, 'punk', 2)");
         stmt.addBatch("INSERT INTO release_group_tag (release_group, tag, count) VALUES (1, 1, 10)");

Modified: search_server/trunk/index/src/test/java/org/musicbrainz/search/index/ReleaseIndexTest.java
===================================================================
--- search_server/trunk/index/src/test/java/org/musicbrainz/search/index/ReleaseIndexTest.java	2013-09-26 12:49:38 UTC (rev 13706)
+++ search_server/trunk/index/src/test/java/org/musicbrainz/search/index/ReleaseIndexTest.java	2013-09-26 14:45:34 UTC (rev 13707)
@@ -43,23 +43,20 @@
     private void addReleaseOne() throws Exception {
         Statement stmt = conn.createStatement();
 
-        stmt.addBatch("INSERT INTO artist_name (id, name) VALUES (1, 'Echo & The Bunnymen')");
-        stmt.addBatch("INSERT INTO artist_name (id, name) VALUES (2, 'Echo and The Bunnymen')");
-
         stmt.addBatch("INSERT INTO artist (id, gid, name, sort_name, comment)" +
-                " VALUES (16153, 'ccd4879c-5e88-4385-b131-bf65296bf245', 1, 2, 'a comment')");
-        stmt.addBatch("INSERT INTO artist_credit (id, name, artist_count, ref_count) VALUES (1, 1, 1, 1)");
+                " VALUES (16153, 'ccd4879c-5e88-4385-b131-bf65296bf245', 'Echo & The Bunnymen', 'Echo and The Bunnymen', 'a comment')");
+        stmt.addBatch("INSERT INTO artist_credit (id, name, artist_count, ref_count) VALUES (1, 'Echo & The Bunnymen', 1, 1)");
         stmt.addBatch("INSERT INTO artist_credit_name (artist_credit, position, artist, name, join_phrase) " +
-                " VALUES (1, 0, 16153, 1, '')");
+                " VALUES (1, 0, 16153, 'Echo & The Bunnymen', '')");
 
-        stmt.addBatch("INSERT INTO release_name (id, name) VALUES (1, 'Crocodiles')");
-        stmt.addBatch("INSERT INTO release_name (id, name) VALUES (2, 'Crocodiles (bonus disc)')");
         stmt.addBatch("INSERT INTO release_group (id, gid, name, artist_credit, type) " +
-                " VALUES (491240, 'efd2ace2-b3b9-305f-8a53-9803595c0e37', 1, 1, 3)");
+                " VALUES (491240, 'efd2ace2-b3b9-305f-8a53-9803595c0e37', 'Crocodiles', 1, 3)");
 
         stmt.addBatch("INSERT INTO release (id, gid, name, artist_credit, release_group, status, packaging, " +
                 "  language, script, comment) " +
-                " VALUES (491240, 'c3b8dbc9-c1ff-4743-9015-8d762819134e', 2, 1, 491240, 1, 1, 1, 1,'demo')");
+                " VALUES (491240, 'c3b8dbc9-c1ff-4743-9015-8d762819134e', 'Crocodiles (bonus disc)', 1, 491240, 1, 1, 1, 1,'demo')");
+
+
         stmt.addBatch("INSERT INTO release_meta (id, amazon_asin) VALUES (491240, 'B00005NTQ7')");
         stmt.addBatch("INSERT INTO medium (id, track_count, release, position, format) VALUES (1, 1, 491240, 1, 7)");
         stmt.addBatch("INSERT INTO medium_cdtoc (id, medium, cdtoc) VALUES (1, 1, 1)");
@@ -67,11 +64,10 @@
         stmt.addBatch("INSERT INTO recording_puid (id, puid, recording) VALUES (1, 1, 2)");
 
         stmt.addBatch("INSERT INTO track (id, recording, medium, position, name, artist_credit, length) "
-                        + " VALUES (1, 2, 1, 4, 2, 1, 33100)");
+                        + " VALUES (1, 2, 1, 4, 'Crocodiles (bonus disc)', 1, 33100)");
 
         stmt.addBatch("INSERT INTO recording(id, gid, name, artist_credit, length)"
-                        + " VALUES (2, '2f250ed2-6285-40f1-aa2a-14f1c05e9765', 1, 1, 33000)");
-
+                        + " VALUES (2, '2f250ed2-6285-40f1-aa2a-14f1c05e9765', 'Crocodiles', 1, 33000)");
         stmt.executeBatch();
         stmt.close();
     }
@@ -84,22 +80,19 @@
     private void addReleaseTwo() throws Exception {
         Statement stmt = conn.createStatement();
 
-        stmt.addBatch("INSERT INTO artist_name (id ,name) VALUES (1, 'Echo & The Bunnymen')");
 
         stmt.addBatch("INSERT INTO artist (id, gid, name, sort_name, comment)" +
-                " VALUES (16153, 'ccd4879c-5e88-4385-b131-bf65296bf245', 1, 1, 'a comment')");
-        stmt.addBatch("INSERT INTO artist_credit (id, name, artist_count, ref_count) VALUES (1, 1, 1, 1)");
-        stmt.addBatch("INSERT INTO artist_credit_name (artist_credit, position, artist, name,join_phrase) " +
-                " VALUES (1, 0, 16153, 1, '')");
+                " VALUES (16153, 'ccd4879c-5e88-4385-b131-bf65296bf245', 'Echo & The Bunnymen', 'Echo and The Bunnymen', 'a comment')");
+        stmt.addBatch("INSERT INTO artist_credit (id, name, artist_count, ref_count) VALUES (1, 'Echo & The Bunnymen', 1, 1)");
+        stmt.addBatch("INSERT INTO artist_credit_name (artist_credit, position, artist, name, join_phrase) " +
+                " VALUES (1, 0, 16153, 'Echo & The Bunnymen', '')");
 
-        stmt.addBatch("INSERT INTO release_name (id, name) VALUES (1, 'Crocodiles')");
-        stmt.addBatch("INSERT INTO release_name (id, name) VALUES (2, 'Crocodiles (bonus disc)')");
-        stmt.addBatch("INSERT INTO release_group (id, gid, name, artist_credit)" +
-                " VALUES (491240, 'efd2ace2-b3b9-305f-8a53-9803595c0e37', 1, 1)");
+        stmt.addBatch("INSERT INTO release_group (id, gid, name, artist_credit) " +
+                " VALUES (491240, 'efd2ace2-b3b9-305f-8a53-9803595c0e37', 'Crocodiles', 1)");
 
-        stmt.addBatch("INSERT INTO release (id, gid, name, artist_credit, release_group, status, packaging," +
-                "  language, script) " +
-                " VALUES (491240, 'c3b8dbc9-c1ff-4743-9015-8d762819134e', 2, 1, 491240, 1, 1, 1, 1)");
+        stmt.addBatch("INSERT INTO release (id, gid, name, artist_credit, release_group, status, packaging, " +
+                "  language, script, comment) " +
+                " VALUES (491240, 'c3b8dbc9-c1ff-4743-9015-8d762819134e', 'Crocodiles (bonus disc)', 1, 491240, 1, 1, 1, 1,'demo')");
 
         stmt.addBatch("INSERT INTO release_country (release, country, date_year, date_month, date_day) values (491241, 221, 1970,1,1)");
         stmt.addBatch("INSERT INTO area (id, name) VALUES (221, 'United Kingdom')");
@@ -120,22 +113,18 @@
     private void addReleaseThree() throws Exception {
         Statement stmt = conn.createStatement();
 
-        stmt.addBatch("INSERT INTO artist_name (id, name) VALUES (1, 'Echo & The Bunnymen')");
-
-        stmt.addBatch("INSERT INTO artist (id, gid, name, sort_name, comment,)" +
-                " VALUES (16153, 'ccd4879c-5e88-4385-b131-bf65296bf245', 1, 1, 'a comment')");
-        stmt.addBatch("INSERT INTO artist_credit (id, name, artist_count, ref_count) VALUES (1, 1, 1, 1)");
+        stmt.addBatch("INSERT INTO artist (id, gid, name, sort_name, comment)" +
+                " VALUES (16153, 'ccd4879c-5e88-4385-b131-bf65296bf245', 'Echo & The Bunnymen', 'Echo and The Bunnymen', 'a comment')");
+        stmt.addBatch("INSERT INTO artist_credit (id, name, artist_count, ref_count) VALUES (1, 'Echo & The Bunnymen', 1, 1)");
         stmt.addBatch("INSERT INTO artist_credit_name (artist_credit, position, artist, name, join_phrase) " +
-                " VALUES (1, 0, 16153, 1,'')");
+                " VALUES (1, 0, 16153, 'Echo & The Bunnymen', '')");
 
-        stmt.addBatch("INSERT INTO release_name (id, name) VALUES (1, 'Crocodiles')");
-        stmt.addBatch("INSERT INTO release_name (id, name) VALUES (2, 'Crocodiles (bonus disc)')");
-        stmt.addBatch("INSERT INTO release_group (id, gid, name, artist_credit)" +
-                " VALUES (491240, 'efd2ace2-b3b9-305f-8a53-9803595c0e37', 1, 1)");
+        stmt.addBatch("INSERT INTO release_group (id, gid, name, artist_credit) " +
+                " VALUES (491240, 'efd2ace2-b3b9-305f-8a53-9803595c0e37', 'Crocodiles', 1)");
 
-        stmt.addBatch("INSERT INTO release (id, gid, name, artist_credit, release_group, packaging," +
-                "  language, script) " +
-                " VALUES (491240, 'c3b8dbc9-c1ff-4743-9015-8d762819134e', 2, 1, 491240, 1, 1, 1)");
+        stmt.addBatch("INSERT INTO release (id, gid, name, artist_credit, release_group, packaging, " +
+                "  language, script, comment) " +
+                " VALUES (491240, 'c3b8dbc9-c1ff-4743-9015-8d762819134e', 'Crocodiles (bonus disc)', 1, 491240, 1, 1, 1, 'demo')");
 
         stmt.addBatch("INSERT INTO release_country (release, country, date_year, date_month, date_day) values (491240, 221, 1970,1,1)");
         stmt.addBatch("INSERT INTO area (id, gid, name, sort_name) VALUES (221, 'c3b8dbc9-c1ff-4743-9015-8d762819134g','United Kingdom','Kingdom of UK')");
@@ -168,18 +157,15 @@
     private void addReleaseFour() throws Exception {
         Statement stmt = conn.createStatement();
 
-        stmt.addBatch("INSERT INTO artist_name (id, name) VALUES (1, 'Echo & The Bunnymen')");
 
         stmt.addBatch("INSERT INTO artist (id, gid, name, sort_name, comment)" +
-                " VALUES (16153, 'ccd4879c-5e88-4385-b131-bf65296bf245', 1, 1, 'a comment')");
-        stmt.addBatch("INSERT INTO artist_credit (id, name, artist_count, ref_count) VALUES (1, 1, 1, 1)");
+                " VALUES (16153, 'ccd4879c-5e88-4385-b131-bf65296bf245', 'Echo & The Bunnymen', 'Echo and The Bunnymen', 'a comment')");
+        stmt.addBatch("INSERT INTO artist_credit (id, name, artist_count, ref_count) VALUES (1, 'Echo & The Bunnymen', 1, 1)");
         stmt.addBatch("INSERT INTO artist_credit_name (artist_credit, position, artist, name, join_phrase) " +
-                " VALUES (1, 0, 16153, 1,'')");
+                " VALUES (1, 0, 16153, 'Echo & The Bunnymen', '')");
 
-        stmt.addBatch("INSERT INTO release_name (id, name) VALUES (1, 'Crocodiles')");
-        stmt.addBatch("INSERT INTO release_name (id, name) VALUES (2, 'Crocodiles (bonus disc)')");
-        stmt.addBatch("INSERT INTO release_group (id, gid, name, artist_credit, type)" +
-                " VALUES (491240, 'efd2ace2-b3b9-305f-8a53-9803595c0e37', 1, 1, 1)");
+        stmt.addBatch("INSERT INTO release_group (id, gid, name, artist_credit,type ) " +
+                " VALUES (491240, 'efd2ace2-b3b9-305f-8a53-9803595c0e37', 'Crocodiles', 1, 1)");
 
         stmt.addBatch("INSERT INTO release_group_secondary_type_join (release_group, secondary_type) VALUES (491240,1)");
         stmt.addBatch("INSERT INTO release_group_secondary_type_join (release_group, secondary_type) VALUES (491240,2)");
@@ -219,18 +205,15 @@
 
         Statement stmt = conn.createStatement();
 
-        stmt.addBatch("INSERT INTO artist_name (id, name) VALUES (1, 'Echo & The Bunnymen')");
 
         stmt.addBatch("INSERT INTO artist (id, gid, name, sort_name, comment)" +
-                " VALUES (16153, 'ccd4879c-5e88-4385-b131-bf65296bf245', 1, 1, 'a comment')");
-        stmt.addBatch("INSERT INTO artist_credit (id, name, artist_count, ref_count) VALUES (1, 1, 1, 1)");
+                " VALUES (16153, 'ccd4879c-5e88-4385-b131-bf65296bf245', 'Echo & The Bunnymen', 'Echo and The Bunnymen', 'a comment')");
+        stmt.addBatch("INSERT INTO artist_credit (id, name, artist_count, ref_count) VALUES (1, 'Echo & The Bunnymen', 1, 1)");
         stmt.addBatch("INSERT INTO artist_credit_name (artist_credit, position, artist, name, join_phrase) " +
-                " VALUES (1, 0, 16153, 1, '')");
+                " VALUES (1, 0, 16153, 'Echo & The Bunnymen', '')");
 
-        stmt.addBatch("INSERT INTO release_name (id, name) VALUES (1, 'Crocodiles')");
-        stmt.addBatch("INSERT INTO release_name (id, name) VALUES (2, 'Crocodiles (bonus disc)')");
         stmt.addBatch("INSERT INTO release_group (id, gid, name, artist_credit) " +
-                " VALUES (491240, 'efd2ace2-b3b9-305f-8a53-9803595c0e37', 1, 1)");
+                " VALUES (491240, 'efd2ace2-b3b9-305f-8a53-9803595c0e37', 'Crocodiles', 1)");
 
         stmt.addBatch("INSERT INTO release (id, gid, name, artist_credit, release_group, status, packaging, " +
                 "  language, script, barcode) " +
@@ -243,11 +226,8 @@
         stmt.addBatch("INSERT INTO area (id, name) VALUES (221, 'United Kingdom')");
         stmt.addBatch("INSERT INTO iso_3166_1 (area, code) VALUES (221, 'GB')");
 
-
-        stmt.addBatch("INSERT INTO label_name (id, name) VALUES (1, 'korova')");
-
         stmt.addBatch("INSERT INTO label (id, gid, name, sort_name,area) " +
-                " VALUES (1, 'a539bb1e-f2e1-4b45-9db8-8053841e7503', 1, 1, 1)");
+                " VALUES (1, 'a539bb1e-f2e1-4b45-9db8-8053841e7503', 'korova', 'korova', 1)");
 
         stmt.addBatch("INSERT INTO release_label (id, release, label, catalog_number) VALUES (1, 491240, 1, 'ECHO1')");
         stmt.addBatch("INSERT INTO release_meta (id, amazon_asin) VALUES (491240, 'B00005NTQ7')");

Modified: search_server/trunk/index/src/test/java/org/musicbrainz/search/index/WorkIndexTest.java
===================================================================
--- search_server/trunk/index/src/test/java/org/musicbrainz/search/index/WorkIndexTest.java	2013-09-26 12:49:38 UTC (rev 13706)
+++ search_server/trunk/index/src/test/java/org/musicbrainz/search/index/WorkIndexTest.java	2013-09-26 14:45:34 UTC (rev 13707)
@@ -37,22 +37,17 @@
 
         Statement stmt = conn.createStatement();
 
-        stmt.addBatch("INSERT INTO artist_name (id, name) VALUES (1, 'Echo & The Bunnymen')");
-        stmt.addBatch("INSERT INTO artist_name (id, name) VALUES (2, 'Echo and The Bunnymen')");
-
         stmt.addBatch("INSERT INTO artist (id, gid, name, sort_name, comment)" +
-                " VALUES (16153, 'ccd4879c-5e88-4385-b131-bf65296bf245', 1, 2, 'a comment')");
+                " VALUES (16153, 'ccd4879c-5e88-4385-b131-bf65296bf245', 'Echo & The Bunnymen', 'Echo and The Bunnymen', 'a comment')");
         stmt.addBatch("INSERT INTO artist_credit (id, name, artist_count, ref_count) VALUES (1, 1, 1, 1)");
         stmt.addBatch("INSERT INTO artist_credit_name (artist_credit, position, artist, name) " +
                 " VALUES (1, 0, 16153, 1)");
 
-        stmt.addBatch("INSERT INTO work_name (id, name) VALUES (1, 'Work')");
-        stmt.addBatch("INSERT INTO work_name (id, name) VALUES (2, 'Play')");
         stmt.addBatch("INSERT INTO work (id, gid, name, artist_credit, comment, language)" +
-                " VALUES (1, 'a539bb1e-f2e1-4b45-9db8-8053841e7503', 1, 1,  'demo', 1)");
+                " VALUES (1, 'a539bb1e-f2e1-4b45-9db8-8053841e7503', 'Work', 1,  'demo', 1)");
         stmt.addBatch("INSERT INTO language (id, iso_code_3, iso_code_2t, iso_code_2b, iso_code_2, name, frequency) " +
                 " VALUES (1, 'eng', 'eng', 'eng', 'en', 'English', 1)");
-        stmt.addBatch("INSERT INTO work_alias (work, name) VALUES (1, 2)");
+        stmt.addBatch("INSERT INTO work_alias (work, name) VALUES (1, 'Play')");
 
         stmt.addBatch("INSERT INTO tag (id, name, ref_count) VALUES (1, 'Classical', 2);");
         stmt.addBatch("INSERT INTO work_tag (work, tag, count) VALUES (1, 1, 10)");
@@ -68,21 +63,16 @@
 
         Statement stmt = conn.createStatement();
 
-        stmt.addBatch("INSERT INTO artist_name (id, name) VALUES (1, 'Echo & The Bunnymen')");
-        stmt.addBatch("INSERT INTO artist_name (id, name) VALUES (2, 'Echo and The Bunnymen')");
-
         stmt.addBatch("INSERT INTO artist (id, gid, name, sort_name, comment)" +
-                " VALUES (16153, 'ccd4879c-5e88-4385-b131-bf65296bf245', 1, 2, 'a comment')");
-
+                " VALUES (16153, 'ccd4879c-5e88-4385-b131-bf65296bf245', 'Echo & The Bunnymen', 'Echo and The Bunnymen', 'a comment')");
         stmt.addBatch("INSERT INTO artist_credit (id, name, artist_count, ref_count) VALUES (1, 1, 1, 1)");
         stmt.addBatch("INSERT INTO artist_credit_name (artist_credit, position, artist, name) " +
                 " VALUES (1, 0, 16153, 1)");
 
-        stmt.addBatch("INSERT INTO work_name (id, name) VALUES (1, 'Work')");
         stmt.addBatch("INSERT INTO work_type (id, name) VALUES (1, 'Opera')");
         
         stmt.addBatch("INSERT INTO work (id, gid, name, artist_credit, type)" +
-                " VALUES (1, 'a539bb1e-f2e1-4b45-9db8-8053841e7503', 1, 1, 1)");
+                " VALUES (1, 'a539bb1e-f2e1-4b45-9db8-8053841e7503', 'Work', 1, 1)");
         stmt.addBatch("INSERT INTO iswc(work,iswc) VALUES(1,'T-101779304-1')");
         stmt.addBatch("INSERT INTO iswc(work,iswc) VALUES(1,'B-101779304-1')");