charmap test using api
[idzebra-moved-to-github.git] / test / api / xpath5.c
1 /* $Id: xpath5.c,v 1.4 2004-12-02 11:28:20 adam Exp $
2    Copyright (C) 2003,2004
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 #include "testlib.h"
24
25
26 /** xpath4.c - Ranking in xpath */
27
28
29 const char *recs[] = {
30         "<record>\n"
31         "  <title>The first title</title>\n"
32         "  <abstract> \n"
33         "    The first common word is the: the the the \n"
34         "    The second common word is word \n"
35         "    but all have the foo bar \n"
36         "  </abstract>\n"
37         "</record>\n",
38
39         "<record>\n"
40         "  <title>The second title</title>\n"
41         "  <abstract> \n"
42         "    The first common word is the: the \n"
43         "    The second common word is foo: foo foo \n"
44         "    but all have the foo bar \n"
45         "  </abstract>\n"
46         "</record>\n",
47
48         "<record>\n"
49         "  <title>The third title</title>\n"
50         "  <abstract> \n"
51         "    The first common word is the: the \n"
52         "    The third common word is bar: bar \n"
53         "    but all have the foo bar \n"
54         "  </abstract>\n"
55         "</record>\n",
56     
57         0 };
58
59
60 int main(int argc, char **argv)
61 {
62     ZebraService zs = start_up("zebraxpath.cfg", argc, argv);
63     ZebraHandle zh = zebra_open(zs);
64     init_data(zh, recs);
65
66 //     yaz_log_init_level(LOG_ALL);
67
68 #define q(qry,hits,string,score) \
69     ranking_query(__LINE__,zh,qry,hits,string,score)
70
71     q("@attr 1=/record/title @attr 2=102 the",
72             3,"first title",952);
73     q("@attr 1=/ @attr 2=102 @or third foo",
74             3,"third title",802);
75
76     q("@attr 1=/ @attr 2=102 foo",
77             3,"second title",850);
78
79     q("@attr 1=/record/ @attr 2=102 foo",
80             3,"second title",927);
81
82     return close_down(zh, zs, 0);
83 }