r13732 - in search_server/trunk: index/src/main/java/org/musicbrainz/search/index index/src/test/java/org/musicbrainz/search/index servlet/src/test/java/org/musicbrainz/search/servlet

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

r13732 - in search_server/trunk: index/src/main/java/org/musicbrainz/search/index index/src/test/java/org/musicbrainz/search/index servlet/src/test/java/org/musicbrainz/search/servlet

root-9
Author: ijabz
Date: 2014-04-24 12:13:28 +0000 (Thu, 24 Apr 2014)
New Revision: 13732

Modified:
   search_server/trunk/index/src/main/java/org/musicbrainz/search/index/LabelIndex.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/LabelIndexTest.java
   search_server/trunk/index/src/test/java/org/musicbrainz/search/index/ReleaseIndexTest.java
   search_server/trunk/servlet/src/test/java/org/musicbrainz/search/servlet/FindLabelTest.java
Log:
SEARCH-355:Label Sortname field removed from Database

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 2014-04-24 10:07:04 UTC (rev 13731)
+++ search_server/trunk/index/src/main/java/org/musicbrainz/search/index/LabelIndex.java 2014-04-24 12:13:28 UTC (rev 13732)
@@ -102,7 +102,7 @@
 
 
         addPreparedStatement("LABELS",
-                "SELECT label.id, label.gid, label.name as name, label.sort_name, " +
+                "SELECT label.id, label.gid, label.name as 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," +
                 "  label.comment, label_code, lower(i.code) as country, " +
@@ -241,15 +241,14 @@
         String name=rs.getString("name");
         doc.addField(LabelIndexField.LABEL,name );
         label.setName(name);
+        doc.addField(LabelIndexField.SORTNAME, name);
+        label.setSortName(name);
 
+
         //Accented artist
         doc.addField(LabelIndexField.LABEL_ACCENT, name );
 
-        String sortName = rs.getString("sort_name");
-        doc.addField(LabelIndexField.SORTNAME, sortName);
-        label.setSortName(sortName);
 
-
         String type = rs.getString("type");
         doc.addFieldOrUnknown(LabelIndexField.TYPE, type);
         if (!Strings.isNullOrEmpty(type)) {
@@ -353,6 +352,8 @@
         String store = MMDSerializer.serialize(label);
         doc.addField(LabelIndexField.LABEL_STORE, store);
 
+
+
         return doc.getLuceneDocument();
     }
 

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 2014-04-24 10:07:04 UTC (rev 13731)
+++ search_server/trunk/index/src/test/java/org/musicbrainz/search/index/AbstractIndexTest.java 2014-04-24 12:13:28 UTC (rev 13732)
@@ -429,7 +429,6 @@
                 "  id serial NOT NULL," +
                 "  gid uuid NOT NULL," +
                 "  name character varying(255)," +
-                "  sort_name character varying(255)," +
                 "  begin_date_year integer," +
                 "  begin_date_month integer," +
                 "  begin_date_day integer," +

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 2014-04-24 10:07:04 UTC (rev 13731)
+++ search_server/trunk/index/src/test/java/org/musicbrainz/search/index/AnnotationIndexTest.java 2014-04-24 12:13:28 UTC (rev 13732)
@@ -127,8 +127,8 @@
 
         Statement stmt = conn.createStatement();
 
-        stmt.addBatch("INSERT INTO label (id, gid, name, sort_name) " +
-                "  VALUES (1, 'a539bb1e-f2e1-4b45-9db8-8053841e7503', '4AD', '4AD')");
+        stmt.addBatch("INSERT INTO label (id, gid, name) " +
+                "  VALUES (1, 'a539bb1e-f2e1-4b45-9db8-8053841e7503', '4AD')");
         
         stmt.addBatch("INSERT INTO annotation (id, editor, text, changelog, created) " +
          "  VALUES (1, 1, 'label annotation', 'change', now())");

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 2014-04-24 10:07:04 UTC (rev 13731)
+++ search_server/trunk/index/src/test/java/org/musicbrainz/search/index/LabelIndexTest.java 2014-04-24 12:13:28 UTC (rev 13732)
@@ -43,8 +43,8 @@
     private void addLabelOne() throws Exception {
 
         Statement stmt = conn.createStatement();
-        stmt.addBatch("INSERT INTO label (id, gid, name, sort_name, type, label_code, begin_date_year, ended) " +
- "VALUES (1, 'a539bb1e-f2e1-4b45-9db8-8053841e7503', '4AD', '4AD US', 4, 5807, 1979, true)");
+        stmt.addBatch("INSERT INTO label (id, gid, name,  type, label_code, begin_date_year, ended) " +
+ "VALUES (1, 'a539bb1e-f2e1-4b45-9db8-8053841e7503', '4AD', 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, '4AD', '4AD US')");
 
@@ -64,9 +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(id, gid, name, sort_name, type, label_code, area, comment, " +
+    stmt.addBatch("INSERT INTO label(id, gid, 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', 'MusicBrainz Data Testing Label', 'Data Testing Label, MusicBrainz', 1, 0099998, 38, 'DO NOT EDIT THIS LABEL', " +
+ "VALUES (2, 'd8caa692-704d-412b-a410-4fbcf5b9c796', 'MusicBrainz Data Testing Label', 1, 0099998, 38, 'DO NOT EDIT THIS LABEL', " +
  " 2009, 1, 1, 2009, 4,false)");
 
         stmt.executeBatch();
@@ -84,8 +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 (id, gid, name, sort_name, area, ended)" +
- "VALUES (3, 'a539bb1e-f2e1-4b45-9db8-8053841e7503', '4AD', '4AD US', 1, true)");
+        stmt.addBatch("INSERT INTO label (id, gid, name, area, ended)" +
+ "VALUES (3, 'a539bb1e-f2e1-4b45-9db8-8053841e7503', '4AD', 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);");
@@ -443,7 +443,7 @@
             assertEquals("a539bb1e-f2e1-4b45-9db8-8053841e7503", label.getId());
             assertEquals("4AD", label.getName());
             assertNull(label.getCountry());
-            assertEquals("4AD US", label.getSortName());
+            assertEquals("4AD", label.getSortName());
             assertNull(label.getDisambiguation());
             assertEquals("Original Production",label.getType());
         }
@@ -469,10 +469,9 @@
             assertEquals("d8caa692-704d-412b-a410-4fbcf5b9c796", label.getId());
             assertEquals("MusicBrainz Data Testing Label", label.getName());
             assertEquals("CA", label.getCountry());
-            assertEquals("Data Testing Label, MusicBrainz",label.getSortName());
+            assertEquals("MusicBrainz Data Testing Label",label.getSortName());
             assertEquals("DO NOT EDIT THIS LABEL", label.getDisambiguation());
             assertEquals("Distributor",label.getType());
-            assertEquals("Data Testing Label, MusicBrainz",label.getSortName());
             LifeSpan lifespan = label.getLifeSpan();
             assertNotNull(lifespan);
             assertEquals("2009-01-01",lifespan.getBegin());

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 2014-04-24 10:07:04 UTC (rev 13731)
+++ search_server/trunk/index/src/test/java/org/musicbrainz/search/index/ReleaseIndexTest.java 2014-04-24 12:13:28 UTC (rev 13732)
@@ -225,11 +225,11 @@
         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 (id, gid, name, sort_name,area) " +
-                " VALUES (1, 'a539bb1e-f2e1-4b45-9db8-8053841e7503', 'korova', 'korova', 1)");
+        stmt.addBatch("INSERT INTO label (id, gid, name,area) " +
+                " VALUES (1, 'a539bb1e-f2e1-4b45-9db8-8053841e7503', 'korova', 1)");
 
-        stmt.addBatch("INSERT INTO label (id, gid, name, sort_name,area) " +
-                " VALUES (2, 'bbbbbbbb-f2e1-4b45-9db8-8053841e7503', 'wea', 'wea', 1)");
+        stmt.addBatch("INSERT INTO label (id, gid, name, area) " +
+                " VALUES (2, 'bbbbbbbb-f2e1-4b45-9db8-8053841e7503', 'wea', 1)");
 
 
         stmt.addBatch("INSERT INTO release_label (id, release, label, catalog_number) VALUES (1, 491240, 1, 'FRED')");

Modified: search_server/trunk/servlet/src/test/java/org/musicbrainz/search/servlet/FindLabelTest.java
===================================================================
--- search_server/trunk/servlet/src/test/java/org/musicbrainz/search/servlet/FindLabelTest.java 2014-04-24 10:07:04 UTC (rev 13731)
+++ search_server/trunk/servlet/src/test/java/org/musicbrainz/search/servlet/FindLabelTest.java 2014-04-24 12:13:28 UTC (rev 13732)
@@ -52,8 +52,8 @@
             doc.addField(LabelIndexField.LABEL, "Jockey Slut");
             label.setName("Jockey Slut");
 
-            doc.addField(LabelIndexField.SORTNAME, "Slut, Jockey");
-            label.setSortName("Slut, Jockey");
+            doc.addField(LabelIndexField.SORTNAME, "Jockey Slut");
+            label.setSortName("Jockey Slut");
 
             doc.addField(LabelIndexField.ALIAS, "Jockeys");
             AliasList aliasList = of.createAliasList();
@@ -253,14 +253,6 @@
             assertEquals("Jockey Slut", doc.get(LabelIndexField.LABEL));
         }
 
-        {
-            Results res = ss.search("\"Slut Jockey\"", 0, 10);
-            assertEquals(1, res.getTotalHits());
-            Result result = res.results.get(0);
-            MbDocument doc = result.getDoc();
-            assertEquals("ff571ff4-04cb-4b9c-8a1c-354c330f863c", doc.get(LabelIndexField.LABEL_ID));
-            assertEquals("Jockey Slut", doc.get(LabelIndexField.LABEL));
-        }
 
         {
             Results res = ss.search("\"Jockeys\"", 0, 10);
@@ -309,8 +301,9 @@
     }
 
     @Test
+    //Pointless because always same value as anme now
     public void testFindLabelBySortname() throws Exception {
-        Results res = ss.search("sortname:\"Slut, Jockey\"", 0, 10);
+        Results res = ss.search("sortname:\"Jockey Slut\"", 0, 10);
         assertEquals(1, res.getTotalHits());
         Result result = res.results.get(0);
         MbDocument doc = result.getDoc();
@@ -464,7 +457,7 @@
         assertTrue(output.contains("id=\"ff571ff4-04cb-4b9c-8a1c-354c330f863c\""));
         assertTrue(output.contains("type=\"Production\""));
         assertTrue(output.contains("<name>Jockey Slut</name>"));
-        assertTrue(output.contains("<sort-name>Slut, Jockey</sort-name>"));
+        assertTrue(output.contains("<sort-name>Jockey Slut</sort-name>"));
         assertTrue(output.contains("begin=\"1993\""));
         assertTrue(output.contains("end=\"2004\""));
     }
@@ -492,7 +485,7 @@
         assertTrue(output.contains("id=\"ff571ff4-04cb-4b9c-8a1c-354c330f863c\""));
         assertTrue(output.contains("type=\"Production\""));
         assertTrue(output.contains("<name>Jockey Slut</name>"));
-        assertTrue(output.contains("<sort-name>Slut, Jockey</sort-name>"));
+        assertTrue(output.contains("<sort-name>Jockey Slut</sort-name>"));
         assertTrue(output.contains("<alias>Jockeys</alias>"));
         assertTrue(output.contains("<begin>1993</begin"));
         assertTrue(output.contains("<end>2004</end>"));
@@ -559,7 +552,7 @@
         assertTrue(output.contains("\"offset\":0,"));
         assertTrue(output.contains("\"type\":\"Production\""));
         assertTrue(output.contains("name\":\"Jockey Slut\""));
-        assertTrue(output.contains("\"sort-name\":\"Slut, Jockey\""));
+        assertTrue(output.contains("\"sort-name\":\"Jockey Slut\""));
         assertTrue(output.contains("life-span\":{\"begin\":\"1993\""));
         assertTrue(output.contains("\"label-code\":1234"));
         assertTrue(output.contains("\"country\":\"GB\""));
@@ -587,7 +580,7 @@
         assertTrue(output.contains("id\":\"ff571ff4-04cb-4b9c-8a1c-354c330f863c\""));
         assertTrue(output.contains("\"type\":\"Production\""));
         assertTrue(output.contains("name\":\"Jockey Slut\""));
-        assertTrue(output.contains("\"sort-name\":\"Slut, Jockey\""));
+        assertTrue(output.contains("\"sort-name\":\"Jockey Slut\""));
         assertTrue(output.contains("life-span\":{\"begin\":\"1993\""));
         assertTrue(output.contains("\"country\":\"GB\""));
         assertTrue(output.contains("\"tags\":[{\"count\":22,\"name\":\"dance\"}]"));


_______________________________________________
MusicBrainz-commits mailing list
[hidden email]
http://lists.musicbrainz.org/mailman/listinfo/musicbrainz-commits
Loading...