Bump year. Change Aps->ApS
[idzebra-moved-to-github.git] / test / api / t10.c
1 /* $Id: t10.c,v 1.6 2005-01-15 19:38:35 adam Exp $
2    Copyright (C) 1995-2005
3    Index Data ApS
4
5 This file is part of the Zebra server.
6
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
10 version.
11
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
15 for more details.
16
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
20 02111-1307, USA.
21 */
22
23 /** t10.c - test zv-rank */
24
25 #include "testlib.h"
26 #include "rankingrecords.h"
27
28 #define qry(zh,query,hits,string,score) \
29     ranking_query(__LINE__,(zh),(query),(hits),(string),(score))
30
31 struct tst {
32     char *schema;
33     char *hit1;
34     int score1;
35     char *hit2;
36     int score2;
37     char *hit3;
38     int score3;
39 };
40
41
42
43 struct tst tests[] = {
44     {"ntc-atn", "first title", 1000, "first title", 1000, "second title",862 },
45     {"ntc-ntn", "first title", 1000, "first title", 1000, "second title",862 },
46     {"ntc-btn", "first title", 1000, "first title", 1000, "second title",862 },
47     {"ntc-apn", "first title", 1000, "first title", 1000, "second title",862 },
48     {"ntc-npn", "first title", 1000, "first title", 1000, "second title",862 },
49     {"ntc-bpn", "first title", 1000, "first title", 1000, "second title",862 },
50
51     {"atc-atn", "first title", 1000, "first title", 1000, "second title", 989 },
52     {"atc-ntn", "first title", 1000, "first title", 1000, "second title", 989 },
53     {"atc-btn", "first title", 1000, "first title", 1000, "second title", 989 },
54     {"atc-apn", "first title", 1000, "first title", 1000, "second title", 989 },
55     {"atc-npn", "first title", 1000, "first title", 1000, "second title", 989 },
56     {"atc-bpn", "first title", 1000, "first title", 1000, "second title", 989 },
57
58     {"npc-atn", "first title", 1000, "first title", 1000, "second title", 862 },
59     {"npc-ntn", "first title", 1000, "first title", 1000, "second title", 862 },
60     {"npc-btn", "first title", 1000, "first title", 1000, "second title", 862 },
61     {"npc-apn", "first title", 1000, "first title", 1000, "second title", 862 },
62     {"npc-npn", "first title", 1000, "first title", 1000, "second title", 862 },
63     {"npc-bpn", "first title", 1000, "first title", 1000, "second title", 862 },
64
65     {"apc-atn", "first title", 1000, "first title", 1000, "second title", 989 },
66     {"apc-ntn", "first title", 1000, "first title", 1000, "second title", 989 },
67     {"apc-btn", "first title", 1000, "first title", 1000, "second title", 989 },
68     {"apc-apn", "first title", 1000, "first title", 1000, "second title", 989 },
69     {"apc-npn", "first title", 1000, "first title", 1000, "second title", 989 },
70     {"apc-bpn", "first title", 1000, "first title", 1000, "second title", 989 },
71
72     {0,0,0,0,0,0,0},
73 };
74
75 int main(int argc, char **argv)
76 {
77     int i;
78     ZebraService zs = start_up("zebrazv.cfg", argc, argv);
79     ZebraHandle  zh = zebra_open (zs);
80   
81     int loglevel=yaz_log_mask_str("zvrank,rank1,t10");
82     init_data(zh, recs);
83     zebra_close(zh);
84     yaz_log_init_level(loglevel);
85     for (i=0; tests[i].schema; i++)
86     {
87         zh = zebra_open (zs);
88         zebra_select_database(zh, "Default");
89         zebra_set_resource(zh, "zvrank.weighting-scheme", tests[i].schema);
90         yaz_log(log_level,"============%d: %s ============", i,tests[i].schema);
91
92         ranking_query( __LINE__, zh, "@attr 1=1016 @attr 2=102 the",
93                 3, tests[i].hit1, tests[i].score1);
94         ranking_query( __LINE__, zh, "@attr 1=1016 @attr 2=102 @or foo bar",
95                 3, tests[i].hit2, tests[i].score2);
96         ranking_query( __LINE__, zh, 
97                 "@attr 1=1016 @attr 2=102 @or @or the foo bar",
98                 3, tests[i].hit3, tests[i].score3);
99
100         zebra_close(zh);
101     }
102     
103     return close_down(0,zs,0);
104 }