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
27 const char *myrec[] = {
30 " <title>My title</title>\n"
36 " <title>My x title</title>\n"
42 " <title>My title x</title>\n"
47 static void tst_sortindex(int argc, char **argv, const char *type)
50 Res res = res_open(0, 0);
52 ZebraService zs = tl_start_up("test_sort3.cfg", argc, argv);
55 res_set(res, "sortindex", type);
57 zh = zebra_open(zs, res);
59 YAZ_CHECK(tl_init_data(zh, myrec));
61 if (strcmp(type, "m"))
63 /* i, f only takes first title into consideration */
70 /* m takes all titles into consideration */
75 YAZ_CHECK(tl_sort(zh, "@or @attr 1=4 title @attr 7=1 @attr 1=4 0", 3, ids));
77 if (strcmp(type, "m"))
79 /* i, f only takes first title into consideration */
86 /* m takes all titles into consideration */
91 YAZ_CHECK(tl_sort(zh, "@or @attr 1=4 title @attr 7=2 @attr 1=4 0", 3, ids));
93 YAZ_CHECK(tl_close_down(zh, zs));
96 static void tst(int argc, char **argv)
98 tst_sortindex(argc, argv, "i");
99 tst_sortindex(argc, argv, "f");
100 tst_sortindex(argc, argv, "m");
108 * c-file-style: "Stroustrup"
109 * indent-tabs-mode: nil
111 * vim: shiftwidth=4 tabstop=8 expandtab