3 /* $Id: xpath5.c,v 1.2 2004-11-01 16:09:05 heikki Exp $
4 Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
7 This file is part of the Zebra server.
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
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
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
28 /** xpath4.c - Ranking in xpath */
31 const char *recs[] = {
33 " <title>The first title</title>\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"
42 " <title>The second title</title>\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"
51 " <title>The third title</title>\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"
62 int main(int argc, char **argv)
64 ZebraService zs = start_up("zebraxpath.cfg", argc, argv);
65 ZebraHandle zh = zebra_open (zs);
68 // yaz_log_init_level(LOG_ALL);
70 #define q(qry,hits,string,score) \
71 ranking_query(__LINE__,zh,qry,hits,string,score)
73 q("@attr 1=/record/title @attr 2=102 the",
75 q("@attr 1=/ @attr 2=102 @or third foo",
78 q("@attr 1=/ @attr 2=102 foo",
79 3,"second title",850);
82 /* FIXME - This query triggers bug #202 */
83 /* http://bugs.index/show_bug.cgi?id=202 */
84 /* it seems that the ranking does not see all occurrences */
85 /* of 'foo', and thus ranks all records as high. */
86 q("@attr 1=/record/ @attr 2=102 foo",
87 3,"second title",846);
90 return close_down(zh, zs, 0);