1 /* $Id: t5.c,v 1.19 2006-08-14 10:40:22 adam Exp $
2 Copyright (C) 1995-2006
5 This file is part of the Zebra server.
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
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
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 /** t5.c: proximity searches */
27 const char *myrec[] = {
28 "<gils>\n<title>My title</title>\n</gils>\n",
29 "<gils>\n<title>My x title</title>\n</gils>\n",
30 "<gils>\n<title>My title x</title>\n</gils>\n" ,
33 static void tst(int argc, char **argv)
35 ZebraService zs = tl_start_up(0, argc, argv);
36 ZebraHandle zh = zebra_open(zs, 0);
38 YAZ_CHECK(tl_init_data(zh, myrec));
41 YAZ_CHECK(tl_query(zh, "@and @attr 1=4 notfound @attr 1=4 x", 0));
42 YAZ_CHECK(tl_query(zh, "@and @attr 1=4 x @attr 1=4 notfound", 0));
43 YAZ_CHECK(tl_query(zh, "@and @attr 1=4 notfound @attr 1=4 notfound", 0));
44 YAZ_CHECK(tl_query(zh, "@and @attr 1=4 x @attr 1=4 x", 2));
45 YAZ_CHECK(tl_query(zh, "@and @attr 1=4 x @attr 1=4 my", 2));
46 YAZ_CHECK(tl_query(zh, "@and @attr 1=4 my @attr 1=4 x", 2));
47 YAZ_CHECK(tl_query(zh, "@and @attr 1=4 my @attr 1=4 my", 3));
50 YAZ_CHECK(tl_query(zh, "@or @attr 1=4 notfound @attr 1=4 x", 2));
51 YAZ_CHECK(tl_query(zh, "@or @attr 1=4 x @attr 1=4 notfound", 2));
52 YAZ_CHECK(tl_query(zh, "@or @attr 1=4 notfound @attr 1=4 notfound", 0));
53 YAZ_CHECK(tl_query(zh, "@or @attr 1=4 x @attr 1=4 x", 2));
54 YAZ_CHECK(tl_query(zh, "@or @attr 1=4 x @attr 1=4 my", 3));
55 YAZ_CHECK(tl_query(zh, "@or @attr 1=4 my @attr 1=4 x", 3));
56 YAZ_CHECK(tl_query(zh, "@or @attr 1=4 my @attr 1=4 my", 3));
60 YAZ_CHECK(tl_query(zh, "@not @attr 1=4 notfound @attr 1=4 x", 0));
61 YAZ_CHECK(tl_query(zh, "@not @attr 1=4 x @attr 1=4 x", 0));
62 YAZ_CHECK(tl_query(zh, "@not @attr 1=4 my @attr 1=4 x", 1));
63 YAZ_CHECK(tl_query(zh, "@not @attr 1=4 my @attr 1=4 notfound", 3));
64 YAZ_CHECK(tl_query(zh, "@not @attr 1=4 notfound @attr 1=4 notfound", 0));
67 YAZ_CHECK(tl_query(zh, "@attr 1=4 my", 3));
68 YAZ_CHECK(tl_query(zh, "@attr 1=4 {my x}", 1));
69 YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=1 {my x}", 1));
70 YAZ_CHECK(tl_query(zh, "@attr 1=4 {my x}", 1));
71 YAZ_CHECK(tl_query(zh, "@attr 1=4 {x my}", 0));
72 YAZ_CHECK(tl_query(zh, "@attr 1=4 {my x title}", 1));
73 YAZ_CHECK(tl_query(zh, "@attr 1=4 {my title}", 2));
75 /* and-list searches */
76 YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=6 {x my}", 2));
77 YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=6 {my x}", 2));
78 YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=6 {my my}", 3));
79 YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=6 {e x}", 0));
81 /* or-list searches */
82 YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=105 {x my}", 3));
83 YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=105 {my x}", 3));
84 YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=105 {my my}", 3));
85 YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=105 {e x}", 2));
86 YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=106 {e x}", 2));
88 /* exl=0 distance=2 order=1 relation=2 (<=), known, unit=word */
89 YAZ_CHECK(tl_query(zh, "@attr 1=4 @prox 0 2 1 2 k 2 my x", 2));
91 /* exl=0 distance=2 order=1 relation=2 (<=), known, unit=word */
92 YAZ_CHECK(tl_query(zh, "@attr 1=4 @prox 0 2 1 2 k 2 x my", 0));
94 /* exl=0 distance=2 order=0 relation=2 (<=), known, unit=word */
95 YAZ_CHECK(tl_query(zh, "@attr 1=4 @prox 0 2 0 2 k 2 x my", 2));
97 /* exl=0 distance=2 order=0 relation=3 (=), known, unit=word */
98 YAZ_CHECK(tl_query(zh, "@attr 1=4 @prox 0 2 1 3 k 2 my x", 1));
100 /* exl=1 distance=2 order=0 relation=3 (=), known, unit=word */
101 YAZ_CHECK(tl_query(zh, "@attr 1=4 @prox 1 2 1 3 k 2 my x", 1));
103 /* provoke unsupported use attribute */
104 YAZ_CHECK(tl_query_x(zh, "@attr 1=999 @attr 4=1 x", 0, 114));
105 YAZ_CHECK(tl_query_x(zh, "@attr 1=999 @attr 4=6 x", 0, 114));
106 YAZ_CHECK(tl_query_x(zh, "@attr 1=999 @attr 4=105 x", 0, 114));
107 YAZ_CHECK(tl_query_x(zh, "@attr 1=999 @attr 4=109 123", 0, 114));
108 YAZ_CHECK(tl_query_x(zh, "@attrset 1.2.840.10003.3.1 @attr 1=999 x",
110 /* provoke unsupported attribute set */
111 YAZ_CHECK(tl_query_x(zh, "@attrset 1.2.8 @attr 1=999 @attr 4=1 x", 0, 121));
112 YAZ_CHECK(tl_query_x(zh, "@attrset 1.2.8 @attr 1=999 @attr 4=6 x", 0,
114 YAZ_CHECK(tl_query_x(zh, "@attrset 1.2.8 @attr 1=999 @attr 4=105 x", 0,
116 YAZ_CHECK(tl_query_x(zh, "@attrset 1.2.8 @attr 1=999 @attr 4=109 123",
119 /* provoke unsupported relation */
120 YAZ_CHECK(tl_query_x(zh, "@attr 1=4 @attr 2=6 x", 0, 117));
121 YAZ_CHECK(tl_query_x(zh, "@attr 1=1016 @attr 2=6 @attr 4=109 x", 0, 114));
123 YAZ_CHECK(tl_close_down(zh, zs));
131 * indent-tabs-mode: nil
133 * vim: shiftwidth=4 tabstop=8 expandtab