Report 'too many characters in search..'
[idzebra-moved-to-github.git] / test / api / test_search.c
index b42d5ee..51b405e 100644 (file)
@@ -1,5 +1,5 @@
 /* This file is part of the Zebra server.
-   Copyright (C) 1994-2009 Index Data
+   Copyright (C) 1994-2011 Index Data
 
 Zebra is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free
@@ -19,6 +19,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 /** \file
     \brief test various search attributes */
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
 #include <yaz/test.h>
 #include "testlib.h"
 
@@ -50,11 +53,23 @@ const char *myrec[] = {
         "</gils>\n",
 
         "<gils>\n<title>My title x</title><abstract>a b c c c a y</abstract>\n</gils>\n" ,
+        "<gils>\n<title>test</title><abstract>a1 a2 c a1 a2 a3</abstract>\n</gils>\n" ,
 
         "<test_search>\n"
         " <date>2107-09-19 00:00:00</date>\n"
         "</test_search>\n"
         ,
+        "<gils>\n"
+        "<title>"
+        "1234567890" "1234567890""1234567890""1234567890""1234567890"
+        "1234567890" "1234567890""1234567890""1234567890""1234567890"
+        "1234567890" "1234567890""1234567890""1234567890""1234567890"
+        "1234567890" "1234567890""1234567890""1234567890""1234567890"
+        "1234567890" "1234567890""1234567890""1234567890""1234567890"
+        "12345"
+        "</title>"
+        "</gils>"
+        ,
        0} ;
        
 static void tst(int argc, char **argv)
@@ -153,14 +168,36 @@ static void tst(int argc, char **argv)
 
     /* string relations, < */
     YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=1 0", 0));
-    YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=1 my", 0));
+    YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=1 my", 1));
 
     /* string relations, <= */
-    YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=2 my", 3));
-    YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=2 mn", 0));
+    YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=2 my", 4));
+    YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=2 mn", 1));
 
     /* = */
     YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=3 my", 3));
+    YAZ_CHECK(
+        tl_query(zh, 
+                 "@attr 1=4 @attr 2=3 "
+                 "1234567890" "1234567890""1234567890""1234567890""1234567890"
+                 "1234567890" "1234567890""1234567890""1234567890""1234567890"
+                 "1234567890" "1234567890""1234567890""1234567890""1234567890"
+                 "1234567890" "1234567890""1234567890""1234567890""1234567890"
+                 "1234567890" "1234567890""1234567890""1234567890""1234567890"
+                 "12345"
+                 , 1));
+    
+    YAZ_CHECK(
+        tl_query_x(zh, 
+                   "@attr 1=4 @attr 2=3 "
+                   "1234567890" "1234567890""1234567890""1234567890""1234567890"
+                   "1234567890" "1234567890""1234567890""1234567890""1234567890"
+                   "1234567890" "1234567890""1234567890""1234567890""1234567890"
+                   "1234567890" "1234567890""1234567890""1234567890""1234567890"
+                   "1234567890" "1234567890""1234567890""1234567890""1234567890"
+                   "123456"
+                   , 0, 11));
+    
 
     /* string relations, >= */
     YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=4 x", 2));
@@ -173,8 +210,8 @@ static void tst(int argc, char **argv)
     YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=5 title", 2));
 
     /* always-matches relation */
-    YAZ_CHECK(tl_query(zh, "@attr 1=_ALLRECORDS @attr 2=103 {ym}", 4));
-    YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=103 {x my}", 3));
+    YAZ_CHECK(tl_query(zh, "@attr 1=_ALLRECORDS @attr 2=103 {ym}", 6));
+    YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=103 {x my}", 5));
     YAZ_CHECK(tl_query_x(zh, "@attr 1=1 @attr 2=103 {x my}", 0, 114));
 
     /* and searches */
@@ -243,6 +280,34 @@ static void tst(int argc, char **argv)
     /* exl=0 distance=2 order=1 relation=2 (<=), known, unit=word */
     YAZ_CHECK(tl_query(zh, "@attr 1=1016 @prox 0 2 1 2 k 2 a y", 1));
 
+    /* exl=0 distance=1 order=1 relation=3 (=), known, unit=word */
+    YAZ_CHECK(tl_query(zh, "@attr 1=1016 @prox 0 1 1 3 k 2 a b", 1));
+
+
+    /* exl=0 distance=1 order=1 relation=3 (=), known, unit=word */
+    YAZ_CHECK(tl_query(zh, "@attr 1=1016 @prox 0 1 1 3 k 2 c a", 1));
+    /* exl=0 distance=1 order=1 relation=2 (<=), known, unit=word */
+    YAZ_CHECK(tl_query(zh, "@attr 1=1016 @prox 0 1 1 2 k 2 c a", 1));
+
+    /* exl=0 distance=1 order=1 relation=2 (<=), known, unit=word */
+    YAZ_CHECK(tl_query(zh, "@attr 1=1016 @prox 0 1 1 2 k 2 @prox 0 1 1 2 k 2 a1 a2 a3", 1));
+    YAZ_CHECK(tl_query(zh, "@attr 1=1016 @prox 0 1 1 3 k 2 @prox 0 1 1 3 k 2 a1 a2 a3", 1));
+
+    /* 3 term @prox test.. */
+    YAZ_CHECK(tl_query(zh, "@attr 1=1016 \"a b c\"", 1));
+
+    /* exl=0 distance=1 order=1 relation=2 (<=), known, unit=word */
+    /* right associative (does not work, so zero hits) */
+    YAZ_CHECK(tl_query(zh, "@attr 1=1016 @prox 0 1 1 2 k 2 a @prox 0 1 1 2 k 2 b c", 0));
+    /* left associative (works fine) */
+    YAZ_CHECK(tl_query(zh, "@attr 1=1016 @prox 0 1 1 2 k 2 @prox 0 1 1 2 k 2 a b c", 1));
+
+    /* exl=0 distance=1 order=1 relation=3 (=), known, unit=word */
+    /* right associative (does not work, so zero hits) */
+    YAZ_CHECK(tl_query(zh, "@attr 1=1016 @prox 0 1 1 3 k 2 a @prox 0 1 1 3 k 2 b c", 0));
+    /* left associative (works fine) */
+    YAZ_CHECK(tl_query(zh, "@attr 1=1016 @prox 0 1 1 3 k 2 @prox 0 1 1 3 k 2 a b c", 1));
+
     /* Non-indexed numeric use, but specified in bib1.att (bug #1142) */
     YAZ_CHECK(tl_query_x(zh, "@attr 1=1000 x", 0, 114));
     YAZ_CHECK(tl_query_x(zh, "@attr 1=1000 @attr 14=0 x", 0, 114));