Samples how to use and extend omindex, the simple file-based indexer
Simple sample index updater:
#!/bin/sh
# _updateindex
if [ "$1" = "all" ]; then
for db in /var/lib/omega/data/*; do
if [ -d "$db" ]; then $0 "$db"; fi
done
exit
fi
if [ ! -d "$1" ]; then
echo "$1 doesn't exist. mkdir /var/lib/omega/data/$1";
echo "_updateindex DBNAME [ SRCDIR ]"
exit
fi
time=`/usr/bin/date +%Y%m%d-%H%M%S`
log="/var/log/omega/updateindex-$1-$time.log"
# default search url (customize this...)
urldir="/s/$1"
if [ ! -z $3 ]; then urldir=$3; fi
# customize this...
case $1 in
DB1) srcdir="//server1/share1" ;;
DB2) srcdir="//server2/share2" ;;
DB3) srcdir="/path3" ;;
esac
# TODO: trap rm db_lock
echo "`date` omindex -p --db /var/lib/omega/data/$1 --url $urldir $srcdir" >> $log
nice omindex -p --db /var/lib/omega/data/$1 --url ${urldir} ${srcdir} ${opts} 2>&1 | tee -a $log
echo "`date` finished update" >> $log
egrep "(added|updated)" $log
Extend omindex
Before extending omindex, you should consider whether scriptindex is more suited to your needs.
Extending omindex in done by adding -M mime mappings and custom filters.
This is a patch by Reini Urban for AVL for non-MSVC, to support "L"last_mod checks (don't update unchanged files), and adds some more tricky file formats - really virtual directories, like zip, rar, pst, mbox files with attachments. The idea of adding a central cache for such virtual directories is not yet implemented here. It also adds a central omindex-error.log.
The last_mod feature should really be supported by omega and xapian by adding this unique field to the document, and the formatted date of the file should be displayed in the query also.
An updated version of this patch is attached to ticket #282.
