:
# http_getindex - find keywords in an index // Nov 16th 1993
# 
# (C) Christian Neuss, Fraunhofer IGD (neuss@igd.fhg.de) 

#--- start of configuration --- put your changes here ---
#  where to find executables
#  Example:
#    BINDIR="/usr/local/httpd/bin" 
BINDIR="/LocalLibrary/SERVER/IndexBin"

# Name of the index file.
# Example:
#  INDEX="/usr/local/httpd/index.idx"
INDEX="/LocalLibrary/SERVER/index/index.idx"

# Name of the thesaurus file.
# Example:
#  THESFILE="/usr/local/httpd/thes.dat"
THESFILE="/igd/a3/home1/neuss/Berkom/thes.dat"
#--- end of configuration --- don't change anything below ---

### query="pic[rut]*e tag foo binary image"
### boolexpr="&+++"

query=`echo "$1" | tr A-Z a-z`
dir="$2"
boolexpr="$4"

EVALUATE="$BINDIR/evaluate-expr"
RELATIONS="AB EQ UF"
THESCMD="$BINDIR/theslookup"

AWKSTR='NF==1 {file=$1}'
GREPSTR='/'

count="0"
for k in $query
do
  count=`expr $count + 1`
  w=`expr $k : '{\(.*\)}'`
  if test -n "$w"
  then
    # evaluate thesaurus:
    words="$w "`$THESCMD "$w" "$RELATIONS" $THESFILE | tr A-Z a-z`" "
  else
    # don't use thesaurus:
    words="$k"
  fi
	for w in $words
	do
	  GREPSTR="$GREPSTR|$w"
    AWKSTR="$AWKSTR "'NF==2 && /[^a-z]'$w'$/ '
    AWKSTR="$AWKSTR"'{printf"%s '$count' %s %s\n",file,$1,$2}'
  done
done

# grep is a lot faster then the awk script, so we save time
# by first grep'ing and then doing awk on the result:
egrep  $GREPSTR < $INDEX | awk "$AWKSTR" | \
egrep "^$dir" |sort | $EVALUATE "$boolexpr"