From Electron Cloud
Here's how to search uploaded files with swish++ (but it's been a while since I did this, so can't guarantee this is all there is to it):
if ( strstr($searchnamespaces, "6") ) { $mediaResults = popen("/usr/local/bin/search -c /usr/local/etc/swish++.conf -i /var/lib/swish/wiki-media.index $this->mRawtext", "r"); $mediaResultCount = 0; # throw away the initial comment $outline = fgets($mediaResults); while (!feof($mediaResults)) { $outline = fgets($mediaResults); list($rank, $fname, $fsize, $ftitle) = explode(" ", $outline, 4); if ($rank) { if (!$mediaResultCount) { $wgOut->addHTML("<H2>Uploaded media matches</H2><OL>"); } $wgOut->addHTML("<LI><a href=" . substr($fname, 19) . ">$ftitle</a> <font size=-2>($fsize bytes) Relevance: $rank</font>"); $mediaResultCount++; } } $wgOut->addHTML("</OL>"); pclose($mediaResults); if (!$mediaResultCount) { $wgOut->addHTML("<H2>No uploaded media matches</H2>"); } }
Obviously /usr/local/etc/swish++.conf must exist, and then you use "index" (one of the swish programs, which has an arrogantly generic name :-) to build /var/lib/swish/wiki-media.index. /usr/local/etc/swish++.conf has all the magic rules about how to extract "words" from every kind of document. Alas I seem to have lost this file. Sigh. I'll do it again someday...