3 # Simple script (and config) to get pz2 to run against DBC's OpenSearch, and
4 # calculate rankings. See how they differ for different queries
10 rm -f $PIDFILE $YAZPIDFILE *.out *.log *.data *~ plot.cmd
17 URL="http://localhost:9017/"
20 PZ="../../src/pazpar2"
23 echo "$PZ2 not executable. Panic"
29 $PZ -f $CFG -l pz2.log -p $PIDFILE &
30 sleep 0.2 # make sure it has time to start
32 curl -s "$URL?command=init" > init.out
33 SESSION=`xml_grep --text_only "//session" init.out `
35 echo "Got session $SESSION"
36 SES="&session=$SESSION"
53 QRY=`echo $Q | sed 's/ /+/g' `
56 SORT="sort=relevance_h"
57 #SEARCH="command=search$SES&$QRY&rank=1&sort=relevance"
58 #SEARCH="command=search$SES&$QRY"
59 #SEARCH="command=search$SES&query=$QRY&sort=relevance"
60 SEARCH="command=search$SES&query=$QRY&$SORT"
62 curl -s "$URL?$SEARCH" > search.out
63 cat search.out | grep search
65 sleep 0.5 # let the search start working
67 STAT="command=stat&$SES"
70 while [ $LOOPING = 1 ]
73 curl -s "$URL?$STAT" > stat.out
74 ACT=`xml_grep --text_only "//activeclients" stat.out`
75 HIT=`xml_grep --text_only "//hits" stat.out`
76 REC=`xml_grep --text_only "//records" stat.out`
78 echo "Hits/Fetched: $HIT / $REC" > stat.line
79 if grep -q "<activeclients>0</activeclients>" stat.out
84 cat stat.out >> stats.out
88 SHOW="command=show$SES&start=0&num=100&$SORT"
90 curl -s "http://localhost:9017/?$SHOW" > show.out
91 #grep "relevance" show.out | grep += | grep -v "(0)"
92 #grep "round-robin" show.out
94 # Plot the lines created by the code
95 grep plotline show.out > scores.data
97 cat scores.data | cut -d' ' -f2 | sort -u
100 grep mergeplot show.out > merge.tmp
103 echo "0 0 0" > merge.data
104 for lno in `cat merge.tmp | cut -d ' ' -f2`
106 if [ "$lno" != "$LAST" ]
108 echo "Found line $lno at $LINENUMBER"
109 grep "mergeplot $lno " merge.tmp | sed "s/mergeplot/$LINENUMBER/" >> merge.data
111 LINENUMBER=$(($LINENUMBER + 1))
114 echo "$LINENUMBER 0 0 0" >> merge.data
118 T1=`grep ": 1 " scores.data | head -1 | cut -d'#' -f2 | cut -d' ' -f2`
119 T2=`grep ": 2 " scores.data | head -1 | cut -d'#' -f2 | cut -d' ' -f2`
120 T3=`grep ": 3 " scores.data | head -1 | cut -d'#' -f2 | cut -d' ' -f2`
121 T4=`grep ": 4 " scores.data | head -1 | cut -d'#' -f2 | cut -d' ' -f2`
122 T5=`grep ": 5 " scores.data | head -1 | cut -d'#' -f2 | cut -d' ' -f2`
123 T6=`grep ": 6 " scores.data | head -1 | cut -d'#' -f2 | cut -d' ' -f2`
128 set title \"$HEADLINE\"
129 plot \"scores.data\" using 0:(\$2==1?\$6:1/0) with points title \"1: $T1\", \
130 \"scores.data\" using 0:(\$2==2?\$6:1/0) with points title \"2: $T2\", \
131 \"scores.data\" using 0:(\$2==3?\$6:1/0) with points title \"3: $T3\", \
132 \"scores.data\" using 0:(\$2==4?\$6:1/0) with points title \"4: $T4\", \
133 \"scores.data\" using 0:(\$2==5?\$6:1/0) with points title \"5: $T5\", \
134 \"scores.data\" using 0:(\$2==6?\$6:1/0) with points title \"6: $T6\"
136 cat plot.cmd | gnuplot
140 set out \"cluster.png\"
141 set title \"$HEADLINE\"
142 plot \"merge.data\" using 1:3 with points title \"records\", \
143 \"merge.data\" using 1:4 with points title \"merged score\", \
144 \"merge.data\" using 1:5 with points title \"sum score\", \
145 \"merge.data\" using 1:6 with points title \"avg score\"
147 cat plot.cmd | gnuplot