In order to get js/ZombieFind working you first need a working copy of swish-e. Getting swish-e working is beyond the scope of this document, but it was fairly straight forward when I installed it. I developed using swish-e version 2.4.5.

If this isn’t your first run make sure to get rid the the b-tree.

rm -rf 0*
rm _0.xml

First step is to get swish-e to index your content and build a data file. You can do some (most, all?) of this on the command line but I used a conf file (swish-e.conf):

# base directory; everything under it will be indexed
IndexDir /some/path
# All the file types you don't want to, or can't index
NoContents .gif .png .jpg .rtf .doc .ico
# convert pdf files to html for the purposes for indexing
FileFilter .pdf /swishpath/filter-bin/_pdf2html.pl
# process .pdf files as html files
IndexContents HTML* .pdf
# Don't index these words they are too common.
IgnoreWords File: /swishpath/conf/stopwords/english.txt
# Repalce the actual root to a relative path to the search results page
# If result page is in the root that just means removing the leading root.
ReplaceRules replace /some/path/

You’ll probably want to edit the swish-e.conf file to index your content according to your requirements.

Once the index is created you want to export the word information and file information.

swish-e -c swish-e.conf
swish-e -T index_words > word.export
swish-e -T index_files > file.export

So the only thing I actually did was write some code that takes those two files (word.export and file.export) and merges them into an xml file in format expected by jsFind.

python -w word.export -f file.export > jsFind.xml

Next we need to run the mkindex.pl for the original jsFind source. However my development box has perl 5.8.8. mkindex.pl uses the command “STDOUT->autoflush(1);” (line 456). I’m not that great at perl but based on error messages this isn’t a valid construct in perl 5.8.8. Replacing that line with much less clear “$|=1;” fixes the problem.

jsfindpath/bin/mkindex.pl index.xml 25

The arguments controls the number of keys in each node and how many layers are generated feel free to play with it. The jsFind documentation has more information.

At this point all the setup is done and it is a matter of creating a search/search results page using the jsFind interface. This was the most difficult piece to figure out.

First include all the required jsFind files.

<SCRIPT type="text/javascript" src="/jsFind/js/getargs.js">/SCRIPT>
<SCRIPT type="text/javascript" src="/jsFind/js/search.js">/SCRIPT>
<SCRIPT type="text/javascript" src="/jsFind/js/usage.js">/SCRIPT>

Where you want the result to appear in your page include the following:

<script> doSearch(args.search, printResults); </script>

printResults is a function that takes an array of objects as an argument. Each of the object has two properties.

  • title - The name of th document.
  • link - The url of the document.

I wrote my own printResult method. I don’t recall if it was becuase the one that came with jsFind didn’t work or it didn’t do what I wanted so here it is.

 function printResults2(result)
{
  var st = ""
  for(var i=result.length-1; i>=0; i--)
  {
    var s = '<div>n' ;
    s += '<a href="' + result[i].link + '">';
    s += result[i].title + '</a><br>';
    s += '<a href="' + result[i].link + '">';
    s += result[i].link.replace(root.slice(8), '') + '</a>';
    s += ' [' +result[i].frequency + ']n';
    s += '</div>n<br>'
    st = st+s
  }
  document.getElementById('search_results').innerHTML = st
}

That should get you up and running. There are many things I’d like to change. Whether I get to it or not remains to be seen.