1 /* This file is part of the Zebra server.
2 Copyright (C) 1994-2011 Index Data
4 Zebra is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
9 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 \brief sort using various sortindex types
30 const char *myrec[] = {
33 " <title>My title</title>\n"
39 " <title>My x title</title>\n"
45 " <title>My title x</title>\n"
50 static void tst_sortindex(int argc, char **argv, const char *type)
53 Res res = res_open(0, 0);
55 ZebraService zs = tl_start_up("test_sort3.cfg", argc, argv);
58 res_set(res, "sortindex", type);
60 zh = zebra_open(zs, res);
62 YAZ_CHECK(tl_init_data(zh, myrec));
64 if (strcmp(type, "m"))
66 /* i, f only takes first title into consideration */
73 /* m takes all titles into consideration */
78 YAZ_CHECK(tl_sort(zh, "@or @attr 1=4 title @attr 7=1 @attr 1=4 0", 3, ids));
80 if (strcmp(type, "m"))
82 /* i, f only takes first title into consideration */
89 /* m takes all titles into consideration */
94 YAZ_CHECK(tl_sort(zh, "@or @attr 1=4 title @attr 7=2 @attr 1=4 0", 3, ids));
96 YAZ_CHECK(tl_close_down(zh, zs));
99 static void tst(int argc, char **argv)
101 tst_sortindex(argc, argv, "i");
102 tst_sortindex(argc, argv, "f");
103 tst_sortindex(argc, argv, "m");
111 * c-file-style: "Stroustrup"
112 * indent-tabs-mode: nil
114 * vim: shiftwidth=4 tabstop=8 expandtab