1 /* $Id: t10.c,v 1.1 2004-10-28 10:37:15 heikki Exp $
2 Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
5 This file is part of the Zebra server.
7 Zebra is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with Zebra; see the file LICENSE.zebra. If not, write to the
19 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23 /** t10.c - test zv-rank */
26 #include <yaz/pquery.h>
27 #include <idzebra/api.h>
29 #include "rankingrecords.h"
31 #define qry(zh,query,hits,string,score) \
32 RankingQuery(__LINE__,(zh),(query),(hits),(string),(score))
46 struct tst tests[] = {
47 {"ntc-atn", "first title", 1000, "first title", 1000, "third title", 826 },
48 {"ntc-ntn", "first title", 1000, "first title", 1000, "third title", 826 },
49 {"ntc-btn", "first title", 1000, "first title", 1000, "third title", 826 },
50 {"ntc-apn", "first title", 1000, "first title", 1000, "third title", 826 },
51 {"ntc-npn", "first title", 1000, "first title", 1000, "third title", 826 },
52 {"ntc-bpn", "first title", 1000, "first title", 1000, "third title", 826 },
54 {"atc-atn", "first title", 1000, "first title", 1000, "first title", 972 },
55 {"atc-ntn", "first title", 1000, "first title", 1000, "first title", 972 },
56 {"atc-btn", "first title", 1000, "first title", 1000, "first title", 972 },
57 {"atc-apn", "first title", 1000, "first title", 1000, "first title", 972 },
58 {"atc-npn", "first title", 1000, "first title", 1000, "first title", 972 },
59 {"atc-bpn", "first title", 1000, "first title", 1000, "first title", 972 },
61 {"npc-atn", "first title", 1000, "first title", 1000, "third title", 826 },
62 {"npc-ntn", "first title", 1000, "first title", 1000, "third title", 826 },
63 {"npc-btn", "first title", 1000, "first title", 1000, "third title", 826 },
64 {"npc-apn", "first title", 1000, "first title", 1000, "third title", 826 },
65 {"npc-npn", "first title", 1000, "first title", 1000, "third title", 826 },
66 {"npc-bpn", "first title", 1000, "first title", 1000, "third title", 826 },
68 {"apc-atn", "first title", 1000, "first title", 1000, "first title", 972 },
69 {"apc-ntn", "first title", 1000, "first title", 1000, "first title", 972 },
70 {"apc-btn", "first title", 1000, "first title", 1000, "first title", 972 },
71 {"apc-apn", "first title", 1000, "first title", 1000, "first title", 972 },
72 {"apc-npn", "first title", 1000, "first title", 1000, "first title", 972 },
73 {"apc-bpn", "first title", 1000, "first title", 1000, "first title", 972 },
78 int main(int argc, char **argv)
85 yaz_log_init_file("t10.log");
86 /* yaz_log_init_level(LOG_ALL); */
90 zs = start_service("zebrazv.cfg");
92 zebra_select_database(zh, "Default");
93 logf(LOG_LOG,"going to call init");
95 logf(LOG_LOG,"init returned %d",i);
97 printf("init failed with %d\n",i);
98 zebra_result(zh, &i, &addinfo);
99 printf(" Error %d %s\n",i,addinfo);
103 zebra_begin_trans (zh, 1);
104 for (i = 0; recs[i]; i++)
105 zebra_add_record (zh, recs[i], strlen(recs[i]));
106 zebra_end_trans (zh);
109 // yaz_log_init_level(LOG_ALL);
114 for (i=0; tests[i].schema; i++)
116 zh = zebra_open (zs);
117 zebra_select_database(zh, "Default");
118 zebra_set_resource(zh, "zvrank.weighting-scheme", tests[i].schema);
119 logf(LOG_LOG,"============%d: %s ============", i,tests[i].schema);
121 RankingQuery( __LINE__, zh, "@attr 1=1016 @attr 2=102 the",
122 3, tests[i].hit1, tests[i].score1);
123 RankingQuery( __LINE__, zh, "@attr 1=1016 @attr 2=102 @or foo bar",
124 3, tests[i].hit2, tests[i].score2);
125 RankingQuery( __LINE__, zh,
126 "@attr 1=1016 @attr 2=102 @or @or the foo bar",
127 3, tests[i].hit3, tests[i].score3);
136 logf(LOG_LOG,"============ ALL TESTS PASSED OK ============");