1 /* This file is part of the Zebra server.
2 Copyright (C) 1994-2010 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 test safari filter
28 "1234\n" /* ID first record */
29 /* chunk owner seq idx term */
30 "00024338 125060 0 1 any the\n"
31 "00024338 125060 0 2 any art\n"
32 "00024338 125060 0 3 any mand\n"
33 "s 00024338 125060 0 3 ti a b c\n"
35 "5678\n" /* other record - same owner id */
36 "00024339 125060 0 1 any den\n"
37 "00024339 125060 0 2 any gamle\n"
38 "00024339 125060 0 3 any mand\n"
39 "s 00024339 125060 0 3 ti d e f\n"
41 "5678\n" /* same record chunk id as before .. */
42 "00024339 125060 0 1 any the\n"
43 "00024339 125060 0 2 any gamle\n"
44 "00024339 125060 0 3 any mand\n"
45 "s 00024339 125060 0 3 ti g h i\n"
47 "1000\n" /* separate record */
48 "00024339 125061 0 1 any the\n"
49 "00024339 125061 0 2 any gamle\n"
50 "00024339 125061 0 3 any mand\n"
51 "w 00024339 125661 0 4 any Hello\n" /* index type given */
52 "s 00024339 125061 0 3 ti j k l\n"
54 "1001\n" /* separate record */
55 "00024340 125062 0 1 any the\n"
56 "00024340 125062 0 1 any the\n" /* DUP KEY, bug #432 */
57 "00024340 125062 0 2 any old\n"
58 "00024340 125062 0 3 any mand\n"
59 "s 00024340 125062 0 3 ti m n o\n"
61 "1002\n" /* segment testing record */
62 "00024341 125062 0 1 title a\n"
63 "00024341 125062 0 2 title b\n"
65 "00024341 125062 1 1024 title b\n"
66 "00024341 125062 1 1025 title c\n"
67 "00024341 125062 1 1026 title d\n"
68 "00024341 125062 1 1027 title e\n"
69 "00024341 125062 1 1028 title f\n"
71 "00024341 125062 2 2048 title g\n"
72 "00024341 125062 2 2049 title c\n"
78 static void tst(int argc, char **argv)
82 ZebraService zs = tl_start_up("test_safari.cfg", argc, argv);
84 ZebraHandle zh = zebra_open(zs, 0);
86 YAZ_CHECK(tl_init_data(zh, myrec));
88 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=any the", 3));
89 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=any den", 0));
90 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=any @and the art", 1));
91 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=any @and den gamle", 0));
92 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=any @and the gamle", 1));
93 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=any @and the of", 0));
95 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=any @prox 0 3 1 2 k 2 the gamle", 1));
96 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=any @prox 0 3 1 2 k 2 den gamle", 0));
97 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=any @prox 0 3 1 2 k 2 the art", 1));
98 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=any @prox 0 3 1 2 k 2 den gamle", 0));
99 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=any @prox 0 3 1 2 k 2 old mand", 1));
101 YAZ_CHECK(tl_query(zh, "@attr 1=any hello", 1));
103 /* verify that we get these records exactly */
107 YAZ_CHECK(tl_meta_query(zh, "@attr 4=3 @attr 1=any mand", 3, ids));
109 YAZ_CHECK_EQ(tl_fetch_compare(zh, 1, "R", yaz_oid_recsyn_sutrs,
110 myrec[0]), ZEBRA_OK);
111 YAZ_CHECK_EQ(tl_fetch_compare(zh, 2, "R", yaz_oid_recsyn_sutrs,
112 myrec[2]), ZEBRA_OK);
113 YAZ_CHECK_EQ(tl_fetch_compare(zh, 3, "R", yaz_oid_recsyn_sutrs,
114 myrec[4]), ZEBRA_OK);
115 YAZ_CHECK_EQ(tl_fetch_compare(zh, 1, "zebra::facet::any:0",
117 "<record xmlns=\"http://www.indexdata.com/zebra/\">\n"
118 " <facet type=\"0\" index=\"any\">\n"
119 " <term coccur=\"4\" occur=\"3\">mand</term>\n"
120 " <term coccur=\"4\" occur=\"3\">the</term>\n"
121 " <term coccur=\"1\" occur=\"1\">art</term>\n"
122 " <term coccur=\"2\" occur=\"1\">gamle</term>\n"
123 " <term coccur=\"1\" occur=\"1\">old</term>\n"
125 "</record>\n"), ZEBRA_OK);
126 YAZ_CHECK_EQ(tl_fetch_compare(zh, 1, "zebra::facet::any:0:2",
128 "<record xmlns=\"http://www.indexdata.com/zebra/\">\n"
129 " <facet type=\"0\" index=\"any\">\n"
130 " <term coccur=\"4\" occur=\"3\">mand</term>\n"
131 " <term coccur=\"4\" occur=\"3\">the</term>\n"
133 "</record>\n"), ZEBRA_OK);
136 YAZ_CHECK_EQ(tl_fetch_compare(zh, 1, "zebra::facet::ti:s",
138 "<record xmlns=\"http://www.indexdata.com/zebra/\">\n"
139 " <facet type=\"s\" index=\"ti\">\n"
140 " <term coccur=\"1\" occur=\"1\">a b c</term>\n"
141 " <term coccur=\"1\" occur=\"1\">j k l</term>\n"
142 " <term coccur=\"1\" occur=\"1\">m n o</term>\n"
144 "</record>\n"), ZEBRA_OK);
146 /* limit to 125061 */
149 zebra_set_limit(zh, 0, limits);
151 YAZ_CHECK(tl_meta_query(zh, "@attr 4=3 @attr 1=any mand", 1, ids));
153 /* limit to 125060, 125061 */
157 zebra_set_limit(zh, 0, limits);
160 YAZ_CHECK(tl_meta_query(zh, "@attr 4=3 @attr 1=any mand", 2, ids));
162 /* all except 125062 */
165 zebra_set_limit(zh, 1, limits);
169 YAZ_CHECK(tl_meta_query(zh, "@attr 4=3 @attr 1=any mand", 2, ids));
172 zebra_set_limit(zh, 1, 0);
173 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=any mand", 3));
176 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=title a", 1));
177 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=title b", 1));
178 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=title c", 1));
180 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=title @and a b", 1));
181 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=title @and a c", 1));
183 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=title @and c d", 1));
184 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=title @and b f", 1));
185 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=title @and f g", 0));
186 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=title @and g f", 0));
187 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=title @and d g", 0));
188 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=title @and g c", 0));
189 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=title @and c g", 0));
190 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=title @and c c", 1));
192 YAZ_CHECK(tl_close_down(zh, zs));
199 * c-file-style: "Stroustrup"
200 * indent-tabs-mode: nil
202 * vim: shiftwidth=4 tabstop=8 expandtab