Improving Searching in OpenGuides

Per a request on the Milton Keynes guide, I took up the matter of looking at making searches include more than just the text of the entry, but instead also listing the metadata in the nodes. I successfully completed this in the following manner:

* Modify the rename.pl in the dist to be more along the lines of: http://crschmidt.net/openguides/reindex.pl
You can see here that this indexes phone address city postcode website fax summary, as well as categories and locales.
* Tested this to make sure the results worked. Number searching seems broken, but other than that it’s in good shape.
* Head in to try and make this change to the underlying guide code.
* Realize that searching is basically hardcoded into write\_node, with no easy way around it. Resign self to this fact and decide that double-indexing is the way to proceed.
* Write a CGI::Wiki Plugin. Bang head against wall until realizing you need to set @ISA yourself.
* Write reindexer similar to reindex.pl above.
* Find “write_node” in Openguides.pm. Place Reindexer plugin above write\_node (see code snippet at end of email).
* Test it out. Seems to work okay.
* Upload Indexer.pm code to http://crschmidt.net/openguides/Indexer.pm
* Post to mailing list.

I’m not sure if anyone else will find this interesting, but I certainly did, so I figured I’d share the knowledge in case anyone else out there wants it.

my $indexer = CGI::Wiki::Plugin::Indexer->new;
$wiki->register_plugin( plugin => $indexer );
$indexer->reindex($node, $content, \%metadata);
my $written = $wiki->write\_node($node, $content, $checksum, \%metadata );

Comments are closed.