r13747 - 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

r13747 - 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-28 14:48:29 +0000 (Mon, 28 Apr 2014)
New Revision: 13747

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/ReleaseIndex.java
   search_server/trunk/index/src/main/java/org/musicbrainz/search/index/ReleaseIndexField.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/FindReleaseTest.java
Log:
SEARCH-341: Allow searching releases with specific packaging type

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 2014-04-28 14:18:26 UTC (rev 13746)
+++ search_server/trunk/index/src/main/java/org/musicbrainz/search/index/CommonTables.java 2014-04-28 14:48:29 UTC (rev 13747)
@@ -100,7 +100,7 @@
                 "  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, " +
                 "  sum(m.track_count) as tracks," +
-                "  r.artist_credit, r.quality," +
+                "  r.artist_credit, r.quality,rp.name as packaging," +
                 "  r.comment" +
                 " FROM release r " +
                 "  LEFT JOIN release_meta rm ON r.id = rm.id " +
@@ -110,8 +110,9 @@
                 "  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" +
+                "  LEFT JOIN release_packaging rp ON r.packaging = rp.id " +
                 " 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.quality, r.comment");
+                "  rm.amazon_asin, language.iso_code_3, language.iso_code_2t, script.iso_code,rs.name,r.artist_credit, r.quality, rp.name,r.comment");
         clock.stop();
         System.out.println("tmp_release     :Finished:" + Utils.formatClock(clock));
         clock.reset();

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 2014-04-28 14:18:26 UTC (rev 13746)
+++ search_server/trunk/index/src/main/java/org/musicbrainz/search/index/ReleaseIndex.java 2014-04-28 14:48:29 UTC (rev 13747)
@@ -175,7 +175,7 @@
                 " SELECT id, gid, name, " +
                 "  barcode, " +
                 "  type, rg_gid, amazon_asin, " +
-                "  language, language_2t, script, status, comment, quality " +
+                "  language, language_2t, script, status, comment, quality, packaging " +
                 " FROM tmp_release rl " +
                 " WHERE id BETWEEN ? AND ? ");
 
@@ -431,7 +431,7 @@
         doc.addFieldOrUnknown(ReleaseIndexField.PRIMARY_TYPE, primaryType);
         ReleaseGroup rg = of.createReleaseGroup();
         release.setReleaseGroup(rg);
-        if (primaryType!=null && !primaryType.isEmpty()){
+        if (!Strings.isNullOrEmpty(primaryType)){
             release.getReleaseGroup().setPrimaryType(primaryType);
         }
 
@@ -446,7 +446,7 @@
 
         String type = ReleaseGroupHelper.calculateOldTypeFromPrimaryType(primaryType, secondaryTypes.get(id));
         doc.addFieldOrUnknown(ReleaseIndexField.TYPE, type);
-        if (type!=null && !type.isEmpty()) {
+        if (!Strings.isNullOrEmpty(type)) {
             release.getReleaseGroup().setType(type);
         }
 
@@ -456,7 +456,7 @@
 
         String status = rs.getString("status");
         doc.addFieldOrUnknown(ReleaseIndexField.STATUS, status);
-        if (status!=null && !status.isEmpty()) {
+        if (!Strings.isNullOrEmpty(status)) {
             release.setStatus(status);
         }
 
@@ -475,7 +475,7 @@
 
         String asin = rs.getString("amazon_asin");
         doc.addFieldOrNoValue(ReleaseIndexField.AMAZON_ID, asin);
-        if (asin!=null && !asin.isEmpty()) {
+        if (!Strings.isNullOrEmpty(asin)) {
             release.setAsin(asin);
         }
 
@@ -483,7 +483,7 @@
         TextRepresentation tr = of.createTextRepresentation();
         String script = rs.getString("script");
         doc.addFieldOrUnknown(ReleaseIndexField.SCRIPT, script) ;
-        if (script!=null && !script.isEmpty()) {
+        if (!Strings.isNullOrEmpty(script)) {
             tr.setScript(script);
             isScriptOrLanguage=true;
         }
@@ -509,9 +509,15 @@
             release.setTextRepresentation(tr);
         }
 
+        String packaging = rs.getString("packaging");
+        doc.addFieldOrUnknown(ReleaseIndexField.PACKAGING, packaging);
+        if (!Strings.isNullOrEmpty(packaging)) {
+            release.setPackaging(packaging);
+        }
+
         String comment = rs.getString("comment");
         doc.addFieldOrNoValue(ReleaseIndexField.COMMENT, comment);
-        if (comment!=null && !comment.isEmpty()) {
+        if (!Strings.isNullOrEmpty(comment)) {
             release.setDisambiguation(comment);
         }
 
@@ -654,6 +660,8 @@
             doc.addFieldOrUnknown(ReleaseIndexField.COUNTRY, null);
             doc.addFieldOrUnknown(ReleaseIndexField.DATE, null );
         }
+
+
         buildClock.suspend();
         storeClock.resume();
         String store = MMDSerializer.serialize(release);

Modified: search_server/trunk/index/src/main/java/org/musicbrainz/search/index/ReleaseIndexField.java
===================================================================
--- search_server/trunk/index/src/main/java/org/musicbrainz/search/index/ReleaseIndexField.java 2014-04-28 14:18:26 UTC (rev 13746)
+++ search_server/trunk/index/src/main/java/org/musicbrainz/search/index/ReleaseIndexField.java 2014-04-28 14:48:29 UTC (rev 13747)
@@ -43,6 +43,7 @@
     STATUS        ("status",    MusicBrainzFieldTypes.TEXT_NOT_STORED_ANALYZED_NO_NORMS, new CaseInsensitiveKeywordAnalyzer()),
     TAG            ("tag",        MusicBrainzFieldTypes.TEXT_NOT_STORED_ANALYZED, new MusicbrainzWithPosGapAnalyzer()),
     TYPE        ("type",    MusicBrainzFieldTypes.TEXT_NOT_STORED_ANALYZED_NO_NORMS, new CaseInsensitiveKeywordAnalyzer()),
+    PACKAGING           ("packaging",       MusicBrainzFieldTypes.TEXT_NOT_STORED_ANALYZED, new CaseInsensitiveKeywordAnalyzer()),
     RELEASE_STORE ("releasestore",    MusicBrainzFieldTypes.TEXT_STORED_NOT_INDEXED),
     ;
 

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-28 14:18:26 UTC (rev 13746)
+++ search_server/trunk/index/src/test/java/org/musicbrainz/search/index/ReleaseIndexTest.java 2014-04-28 14:48:29 UTC (rev 13747)
@@ -629,6 +629,23 @@
      * @throws Exception exception
      */
     @Test
+    public void testIndexReleasePackaging() throws Exception {
+
+        addReleaseOne();
+        RAMDirectory ramDir = new RAMDirectory();
+        createIndex(ramDir);
+
+        IndexReader ir = DirectoryReader.open(ramDir);
+        assertEquals(2, ir.numDocs());
+        {
+            checkTerm(ir,ReleaseIndexField.PACKAGING,"jewel case");
+        }
+        ir.close();
+    }
+    /**
+     * @throws Exception exception
+     */
+    @Test
     public void testIndexReleaseQuality() throws Exception {
 
         addReleaseOne();
@@ -855,6 +872,7 @@
             assertEquals("Official", release.getStatus());
             assertEquals("EP", release.getReleaseGroup().getPrimaryType());
             assertEquals("EP", release.getReleaseGroup().getType());
+            assertEquals("Jewel Case", release.getPackaging());
             assertNotNull(release.getMediumList());
             assertEquals(1,release.getMediumList().getCount().intValue());
             assertEquals(1,release.getMediumList().getTrackCount().intValue());

Modified: search_server/trunk/servlet/src/test/java/org/musicbrainz/search/servlet/FindReleaseTest.java
===================================================================
--- search_server/trunk/servlet/src/test/java/org/musicbrainz/search/servlet/FindReleaseTest.java 2014-04-28 14:18:26 UTC (rev 13746)
+++ search_server/trunk/servlet/src/test/java/org/musicbrainz/search/servlet/FindReleaseTest.java 2014-04-28 14:48:29 UTC (rev 13747)
@@ -104,6 +104,10 @@
             stl.getSecondaryType().add("Compilation");
             release.getReleaseGroup().setSecondaryTypeList(stl);
 
+
+            doc.addField(ReleaseIndexField.PACKAGING, "Jewel Case");
+            release.setPackaging("Jewel Case");
+
             doc.addField(ReleaseIndexField.QUALITY, ReleaseQuality.HIGH.toString());
             doc.addField(ReleaseIndexField.TAG, "punk");
             TagList tagList = of.createTagList();
@@ -500,6 +504,13 @@
         assertEquals("1d9e8ed6-3893-4d3b-aa7d-6cd79609e386", getReleaseId(res.results.get(0).getDoc()));
     }
 
+    @Test
+    public void testFindReleaseByPackaging() throws Exception {
+        Results res = ss.search("packaging:\"jewel case\"", 0, 10);
+        assertEquals(1, res.getTotalHits());
+        assertEquals("1d9e8ed6-3893-4d3b-aa7d-6cd79609e386", getReleaseId(res.results.get(0).getDoc()));
+    }
+
     /**
      * Works as is even though lang code not analysed because lang code always lowercase
      *
@@ -804,6 +815,7 @@
         assertTrue(output.contains("<name>United Kingdom</name>"));
         assertTrue(output.contains("<sort-name>United Kingdom</sort-name>"));
         assertTrue(output.contains("<format>Vinyl</format>"));
+        assertTrue(output.contains("<packaging>Jewel Case</packaging>"));
         assertTrue(output.contains("<asin>B00004Y6O9</asin>"));
         assertTrue(output.contains("<track-count>17</track-count>"));
         assertTrue(output.contains("<name>Wrath Records</name>"));
@@ -843,6 +855,7 @@
         assertTrue(output.contains("\"secondary-type-list\":{\"secondary-type\":[\"Live\",\"Compilation\"]}}"));
         assertTrue(output.contains("{\"release-event\":[{\"date\":\"2005\""));
         assertTrue(output.contains("\"name\":\"United Kingdom\","));
+        assertTrue(output.contains("\"packaging\":\"Jewel Case\","));
         assertTrue(output.contains("\"sort-name\":\"United Kingdom\","));
         assertTrue(output.contains("\"id\":\"1fa8aa07-c688-1f7c-734b-4d82e528b09b\","));
     }
@@ -876,6 +889,7 @@
         assertTrue(output.contains("\"track-count\":7"));
         assertTrue(output.contains("\"label-info\""));
         assertTrue(output.contains("\"catalog-number\":\"WRATHCD-25\""));
+        assertTrue(output.contains("\"packaging\":\"Jewel Case\","));
         assertTrue(output.contains("\"primary-type\":\"Album\""));
         assertTrue(output.contains("\"release-events\":[{\"date\":\"2005\""));
         assertTrue(output.contains("\"secondary-types\":[\"Live\",\"Compilation\"]}"));


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