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

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

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

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

Added:
   search_server/trunk/servlet/src/main/java/org/musicbrainz/search/servlet/ArtistDismaxQueryParser.java
   search_server/trunk/servlet/src/main/java/org/musicbrainz/search/servlet/ArtistDismaxSearcher.java
Modified:
   search_server/trunk/servlet/src/main/java/org/musicbrainz/search/servlet/ArtistDismaxSearch.java
   search_server/trunk/servlet/src/main/java/org/musicbrainz/search/servlet/DismaxQueryParser.java
   search_server/trunk/servlet/src/test/java/org/musicbrainz/search/servlet/FindArtistTest.java
   search_server/trunk/servlet/src/test/java/org/musicbrainz/search/servlet/FindReleaseTest.java
   search_server/trunk/servlet/src/test/java/org/musicbrainz/search/servlet/IssueSearch167Test.java
Log:
SEARDCH-339:MB search requires minimum of 4 characters to consider second name

Modified: search_server/trunk/servlet/src/main/java/org/musicbrainz/search/servlet/ArtistDismaxSearch.java
===================================================================
--- search_server/trunk/servlet/src/main/java/org/musicbrainz/search/servlet/ArtistDismaxSearch.java 2014-04-24 12:58:33 UTC (rev 13733)
+++ search_server/trunk/servlet/src/main/java/org/musicbrainz/search/servlet/ArtistDismaxSearch.java 2014-04-24 13:30:30 UTC (rev 13734)
@@ -17,7 +17,7 @@
     DismaxAlias dismaxAlias = new DismaxAlias();
     dismaxAlias.setFields(fieldBoosts);
     dismaxAlias.setTie(0.1f);
-    return new DismaxSearcher(dismaxAlias);
+    return new ArtistDismaxSearcher(dismaxAlias);
   }
 
   /**

Modified: search_server/trunk/servlet/src/main/java/org/musicbrainz/search/servlet/DismaxQueryParser.java
===================================================================
--- search_server/trunk/servlet/src/main/java/org/musicbrainz/search/servlet/DismaxQueryParser.java 2014-04-24 12:58:33 UTC (rev 13733)
+++ search_server/trunk/servlet/src/main/java/org/musicbrainz/search/servlet/DismaxQueryParser.java 2014-04-24 13:30:30 UTC (rev 13734)
@@ -152,10 +152,16 @@
             return fq;
         }
 
-
+        @Override
         protected Query getFieldQuery(String field, String queryText, boolean quoted)
                 throws ParseException
         {
+            return getFieldQuery(field, queryText, quoted, MIN_FIELD_LENGTH_TO_MAKE_FUZZY);
+        }
+
+        protected Query getFieldQuery(String field, String queryText, boolean quoted, int fuzzyFieldLength)
+                throws ParseException
+        {
             //If field is an alias
             if (aliases.containsKey(field)) {
 
@@ -171,7 +177,7 @@
                     Query queryFuzzy = null;
 
                     DismaxAlias.AliasField af = a.getFields().get(f);
-                    if (!quoted && queryText.length() >= MIN_FIELD_LENGTH_TO_MAKE_FUZZY) {
+                    if (!quoted && queryText.length() >= fuzzyFieldLength) {
                         querySub = getFieldQuery(f, queryText, quoted);
                         if (querySub instanceof TermQuery) {
 

Modified: search_server/trunk/servlet/src/test/java/org/musicbrainz/search/servlet/FindArtistTest.java
===================================================================
--- search_server/trunk/servlet/src/test/java/org/musicbrainz/search/servlet/FindArtistTest.java 2014-04-24 12:58:33 UTC (rev 13733)
+++ search_server/trunk/servlet/src/test/java/org/musicbrainz/search/servlet/FindArtistTest.java 2014-04-24 13:30:30 UTC (rev 13734)
@@ -258,6 +258,14 @@
     }
 
     @Test
+    public void testFindArtistDismaxFuzzyShort() throws Exception {
+        Results res = sd.search("Fa", 0, 10);
+        assertEquals(1, res.getTotalHits());
+        assertEquals("4302e264-1cf0-4d1f-aca7-2a6f89e34b36", getArtistId(res.results.get(0).getDoc()));
+
+    }
+
+    @Test
     public void testFindArtistBySortName() throws Exception {
         Results res = ss.search("sortname:\"Incident, Farming\"", 0, 10);
         assertEquals(1, res.getTotalHits());

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-24 12:58:33 UTC (rev 13733)
+++ search_server/trunk/servlet/src/test/java/org/musicbrainz/search/servlet/FindReleaseTest.java 2014-04-24 13:30:30 UTC (rev 13734)
@@ -338,6 +338,19 @@
     }
 
     @Test
+    public void testFindReleaseByDismax3Short() throws Exception {
+        Results res = sd.search("Inci", 0, 10);
+        assertEquals(1, res.getTotalHits());
+        assertEquals("1d9e8ed6-3893-4d3b-aa7d-6cd79609e386", getReleaseId(res.results.get(0).getDoc()));
+    }
+
+    @Test
+    public void testFindReleaseByDismax3TooShort() throws Exception {
+        Results res = sd.search("Inc", 0, 10);
+        assertEquals(0, res.getTotalHits());
+    }
+
+    @Test
     public void testFindReleaseByDismax4() throws Exception {
         Results res = sd.search("Our Glorious", 0, 10);
         assertEquals(1, res.getTotalHits());

Modified: search_server/trunk/servlet/src/test/java/org/musicbrainz/search/servlet/IssueSearch167Test.java
===================================================================
--- search_server/trunk/servlet/src/test/java/org/musicbrainz/search/servlet/IssueSearch167Test.java 2014-04-24 12:58:33 UTC (rev 13733)
+++ search_server/trunk/servlet/src/test/java/org/musicbrainz/search/servlet/IssueSearch167Test.java 2014-04-24 13:30:30 UTC (rev 13734)
@@ -379,13 +379,13 @@
     }
 
     @Test
-    public void testFindArtistDismaxTooShortForWildcard() throws Exception {
+    public void testFindArtistDismaxShortWildcard() throws Exception {
         SearcherManager searcherManager = sd.getSearcherManager();
         IndexSearcher searcher = searcherManager.acquire();
         try {
             Query q = sd.parseQuery("Rep");
             TopDocs topdocs = searcher.search(q, 10);
-            assertEquals(0, topdocs.scoreDocs.length);
+            assertEquals(4, topdocs.scoreDocs.length);
         } finally {
             searcherManager.release(searcher);
         }


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