Added a test for ranking together with xpath -
[idzebra-moved-to-github.git] / test / api / xpath5.c
1
2
3 /* $Id: xpath5.c,v 1.1 2004-11-01 11:45:39 heikki Exp $
4    Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
5    Index Data Aps
6
7 This file is part of the Zebra server.
8
9 Zebra is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free
11 Software Foundation; either version 2, or (at your option) any later
12 version.
13
14 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
17 for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with Zebra; see the file LICENSE.zebra.  If not, write to the
21 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 02111-1307, USA.
23 */
24
25 #include "testlib.h"
26
27
28 /** xpath4.c - Ranking in xpath */
29
30
31 const char *recs[] = {
32         "<record>\n"
33         "  <title>The first title</title>\n"
34         "  <abstract> \n"
35         "    The first common word is the: the the the \n"
36         "    The second common word is word \n"
37         "    but all have the foo bar \n"
38         "  </abstract>\n"
39         "</record>\n",
40
41         "<record>\n"
42         "  <title>The second title</title>\n"
43         "  <abstract> \n"
44         "    The first common word is the: the \n"
45         "    The second common word is foo: foo foo \n"
46         "    but all have the foo bar \n"
47         "  </abstract>\n"
48         "</record>\n",
49
50         "<record>\n"
51         "  <title>The third title</title>\n"
52         "  <abstract> \n"
53         "    The first common word is the: the \n"
54         "    The third common word is bar: bar \n"
55         "    but all have the foo bar \n"
56         "  </abstract>\n"
57         "</record>\n",
58     
59         0 };
60
61
62 int main(int argc, char **argv)
63 {
64     ZebraService zs = start_up("zebraxpath.cfg", argc, argv);
65     ZebraHandle zh = zebra_open (zs);
66     init_data(zh,recs);
67
68 //     yaz_log_init_level(LOG_ALL);
69
70 #define q(qry,hits,string,score) \
71     ranking_query(__LINE__,zh,qry,hits,string,score)
72
73     q("@attr 1=/record/title @attr 2=102 the",
74             3,"first title",846);
75     q("@attr 1=/ @attr 2=102 @or third foo",
76             3,"third title",802);
77
78     q("@attr 1=/ @attr 2=102 foo",
79             3,"second title",850);
80     /* FIXME - This query triggers bug #202 */
81     /* http://bugs.index/show_bug.cgi?id=202 */
82     /* it seems that the ranking does not see all occurrences */
83     /* of 'foo', and thus ranks all records as high. */
84     /*
85     q("@attr 1=/record/ @attr 2=102 foo",
86             3,"second title",846);
87      Ø*/
88     return close_down(zh, zs, 0);
89 }