Better Javadoc results using SearchMonkey

When you are searching for things like java.util.HashMap one of the issues that you run into is that it will give you the result with the highest rank which more often than not is the 1.4.2 version of the documentation.  I’ve moved on from that version of Java and would much rather see results for version 6.  I actually did this plugin back in December for the first SearchMonkey hackday and won “most useful” as it could be extended to any type of versioned documentation you might find on the web.  Today I’ll also include my plugin for MySQL but I’ll use Java as the example.

Here is the normal search result that you get on Yahoo:

Normal search result

What I would like to do is give some more options for the user.  Eventually I expect that SearchMonkey might allow per user preferences, but in the interim, I’ll produce links for 1.4.2, 1.5, 1.6 and a link to the entries package page:

Enhanced search result

This gives you direct access to other versions of the classes documentation from the search result page without having to qualify your search terms or scroll through pages of results looking for the one most relevant to you as a developer.  To create this enhanced result go to the SearchMonkey Developer Tool and create a new application.  Choose Enhanced Result rather than Infobar.  The URL pattern that I used was “**”.  Obviously the real work is done in the PHP code for the appearance of the enhanced result:

public static function getOutput() {
    $ret = array();   

$classname = Data::get('yahoo:index/dc:identifier');
    $pattern = "/.*\/docs\/api\/(.*\/[A-Z].*).html/";
    if (preg_match($pattern, $classname, $matches)) {
        $classname = $matches[1];
        $link = $classname;
        $classname = str_replace("/", ".", $classname);
    } else {
        return $ret;

/* pull the package reference out */
    if (preg_match("/(.*)\.([^.]+)/", $classname, $matches)) {
        $packagename = $matches[1];

/* change the title to the name of the class */
    $ret['title'] = $classname;

// Deep links - up to 4
    $ret['links'][0]['text'] = "1.6.0";
    $ret['links'][0]['href'] = "" . $link . ".html";
    $ret['links'][1]['text'] = "1.5.0";
    $ret['links'][1]['href'] = "" . $link . ".html";;
    $ret['links'][2]['text'] = "1.4.2";
    $ret['links'][2]['href'] = "" . $link . ".html";
    $ret['links'][3]['text'] = $packagename;
    $ret['links'][3]['href'] = "" . str_replace(".", "/", $packagename) . "/package-summary.html";

return $ret;

Once that is done you confirm that you are finished and you will then see these enhanced result when you use  Here are links to my applications that you can import into your own developer environment:




This entry was posted in Java, Technology and tagged , , , , . Bookmark the permalink.
  • Alex Miller

    I often would like to see not only the javadoc but links to the source, even links to different versions of the source (by both JDK version and impl – Sun, Harmony, etc).

  • sam

    Good idea. I’m looking at things to put in the Infobar and those make a lot of sense.

  • ScottE

    I’ve found adding the words “SE 5” to the google search term gives me the java 5 results first. A hack, but it works for me…

  • Shivram Mani

    good one … ur idea makes sense for a whole lot of content

  • Leon B Walker

    great article!, grats for u site :)

  • Barbara J Najera

    god bless your blog my friend :)

  • Barbara J Najera

    god bless your blog my friend :)