Anonymous avatar Anonymous committed e892e1d

account for Search not including short words in position calculation

related to bz://732

Comments (0)

Files changed (1)

apps/wriaki/priv/mapred/search_map.js

         // extract the phrases from the text
         var text = JSON.parse(v.values[0].data).text;
         var words = text.match(/[a-z0-9\u80-\uff]*/g).filter(
-            function(s) { return s != ""; }).length
+            function(s) { return s != "" && s.length > 2; }).length
 
         for (var i = 0; i < result.ranges.length; i++) {
             var s = result.ranges[i].start < 5 ?
             // regexp is basically "match START words, then grab everything
             // until WORDS-END words from the end"
             var match = (new RegExp(
-                "(?:[a-z0-9\u80-\uff]+[^a-z0-9\u80-\uff]+){"+s+"}"+
+                "(?:[a-z0-9\u80-\uff]{3,}[^a-z0-9\u80-\uff]+"+
+                    "(?:(?:[a-z0-9\u80-\uff]|[a-z0-9\u80-\uff][a-z0-9\u80-\uff])"+
+                     "[^a-z0-9\u80-\uff]+)*"+
+                    "){"+s+"}"+
                 "(.*)[^a-z0-9\u80-\uff]"+
-                "(?:[a-z0-9\u80-\uff]+[^a-z0-9\u80-\uff]+){"+(words-e)+"}"))
+                "(?:[a-z0-9\u80-\uff]{3,}[^a-z0-9\u80-\uff]+"+
+                    "(?:(?:[a-z0-9\u80-\uff]|[a-z0-9\u80-\uff][a-z0-9\u80-\uff])"+
+                     "[^a-z0-9\u80-\uff]+)*"+
+                    "){"+(words-e)+"}"))
                 .exec(text);
             result.ranges[i] = match[1];
         }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.