Simple cluster range merging r += r[i] / i
[pazpar2-moved-to-github.git] / heikki / test1.sh
1 #!/bin/bash
2 #
3 # Simple script (and config) to get pz2 to run against yaz-ztest, and 
4 # calculate rankings. See how they differ for different queries
5 #
6 # (uses curl and xml-twig-tools)
7
8 if [ "$1" == "clean" ]
9 then
10   echo "Cleaning up"
11   rm -f $PIDFILE $YAZPIDFILE *.out *.log *~ 
12   exit
13 fi
14
15 URL="http://localhost:9017/"
16 CFG="test1.cfg"
17
18 PZ="../src/pazpar2"
19
20 PIDFILE=pz2.pid
21
22 YAZPIDFILE=yaz-ztest.pid
23 yaz-ztest -p $YAZPIDFILE -l yaz-ztest.log &
24
25 rm -f *.out *.log
26
27 $PZ -f $CFG  -l pz2.log -p $PIDFILE &
28 sleep 0.2 # make sure it has time to start
29 echo "Init"
30 curl -s "$URL?command=init" > init.out
31 SESSION=`xml_grep --text_only "//session" init.out `
32 # cat init.out; echo
33 echo "Got session $SESSION"
34 SES="&session=$SESSION"
35
36
37 QRY="query=computer"
38 #SEARCH="command=search$SES&$QRY&rank=1&sort=relevance"
39 #SEARCH="command=search$SES&$QRY"
40 SEARCH="command=search$SES&$QRY&sort=relevance"
41 echo $SEARCH
42 curl -s "$URL?$SEARCH" > search.out
43 cat search.out | grep search
44 echo
45
46 STAT="command=stat&$SES"
47 echo "" > stat.out
48 LOOPING=1
49 while [ $LOOPING = 1 ]
50 do
51   sleep 0.5
52   curl -s "$URL?$STAT" > stat.out
53   ACT=`xml_grep --text_only "//activeclients" stat.out`
54   HIT=`xml_grep --text_only "//hits" stat.out`
55   REC=`xml_grep --text_only "//records" stat.out`
56   echo "$ACT $HIT $REC"
57   if grep -q "<activeclients>0</activeclients>" stat.out
58   then
59     LOOPING=0
60   fi
61   echo >> stats.out
62   cat stat.out >> stats.out
63 done
64
65
66 SHOW="command=show$SES&sort=relevance_h&start=0&num=100"
67 echo $SHOW
68 curl -s "http://localhost:9017/?$SHOW" > show.out
69 #grep "relevance" show.out | grep += | grep -v "(0)"
70 grep "round-robin" show.out
71
72 # Plot it
73 grep "round-robin" show.out |
74   cut -d' ' -f 6,7 |
75   sed 's/[^0-9 ]//g' |
76   awk '{print FNR,$0}'> plot.data
77
78 echo '\
79   set term png
80   set out "plot.png"
81   plot "plot.data" using 1:2  with points  title "tf/idf", \
82        "plot.data" using 1:($3*300)  with points  title "round-robin"
83  ' | gnuplot
84
85 echo
86
87 echo "All done"
88 kill `cat $PIDFILE`
89 kill `cat $YAZPIDFILE`
90 rm -f $PIDFILE $YAZPIDFILE
91