Fix problem with generic proximity handling.
[idzebra-moved-to-github.git] / test / api / test_search.c
index 54fe529..b42d5ee 100644 (file)
@@ -1,5 +1,5 @@
 /* This file is part of the Zebra server.
-   Copyright (C) 1995-2008 Index Data
+   Copyright (C) 1994-2009 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
@@ -30,8 +30,9 @@ const char *myrec[] = {
         "    <East-Bounding-Coordinate> -102 </East-Bounding-Coordinate>\n"
         "    <North-Bounding-Coordinate>  49 </North-Bounding-Coordinate>\n"
         "    <South-Bounding-Coordinate>  31 </South-Bounding-Coordinate>\n"
-        "  </Bounding-Coordinates></Spatial-Domain>"
+        "  </Bounding-Coordinates></Spatial-Domain>\n"
         "</gils>\n",
+
         "<gils>\n<title>My x title</title>\n"
         "  <abstract>second test with two coord sets</abstract>\n"
         "  <Spatial-Domain><Bounding-Coordinates>\n"
@@ -45,9 +46,15 @@ const char *myrec[] = {
         "    <East-Bounding-Coordinate> -108 </East-Bounding-Coordinate>\n"
         "    <North-Bounding-Coordinate>  41 </North-Bounding-Coordinate>\n"
         "    <South-Bounding-Coordinate>  25 </South-Bounding-Coordinate>\n"
-        "  </Bounding-Coordinates></Spatial-Domain>"
+        "  </Bounding-Coordinates></Spatial-Domain>\n"
         "</gils>\n",
-        "<gils>\n<title>My title x</title>\n</gils>\n" ,
+
+        "<gils>\n<title>My title x</title><abstract>a b c c c a y</abstract>\n</gils>\n" ,
+
+        "<test_search>\n"
+        " <date>2107-09-19 00:00:00</date>\n"
+        "</test_search>\n"
+        ,
        0} ;
        
 static void tst(int argc, char **argv)
@@ -60,20 +67,31 @@ static void tst(int argc, char **argv)
     /* simple term */
     YAZ_CHECK(tl_query(zh, "@attr 1=4 notfound", 0));
     YAZ_CHECK(tl_query(zh, "@attr 1=4 title", 3));
-    tl_fetch_compare(zh, 1, "zebra::facet::title:w", yaz_oid_recsyn_sutrs,
-                     "term 3 3: my\n"
-                     "term 3 3: title\n"
-                     "term 2 2: x\n");
+    YAZ_CHECK_EQ(tl_fetch_compare(zh, 1, "zebra::facet::title:w",
+                                  yaz_oid_recsyn_sutrs,
+                                  "facet w title\n"
+                                  "term 3 3: my\n"
+                                  "term 3 3: title\n"
+                                  "term 2 2: x\n"), ZEBRA_OK);
+    
+    YAZ_CHECK_EQ(tl_fetch_compare(zh, 1, "zebra::facet::title:s",
+                                  yaz_oid_recsyn_sutrs,
+                                  "facet s title\n"
+                                  "term 1 1: my title\n"
+                                  "term 1 1: my title x\n"
+                                  "term 1 1: my x title\n"), ZEBRA_OK);
 
     /* trunc right */
     YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=1 titl", 3));
 
     YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=1 x", 2));
-    tl_fetch_compare(zh, 1, "zebra::facet::title:w", yaz_oid_recsyn_sutrs,
-                     "term 2 2: my\n"
-                     "term 2 2: title\n"
-                     "term 2 2: x\n");
-
+    YAZ_CHECK_EQ(tl_fetch_compare(zh, 1, "zebra::facet::title:w",
+                                  yaz_oid_recsyn_sutrs,
+                                  "facet w title\n"
+                                  "term 2 2: my\n"
+                                  "term 2 2: title\n"
+                                  "term 2 2: x\n"), ZEBRA_OK);
+                 
     /* trunc left */
     YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=2 titl", 0));
     YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=2 x", 2));
@@ -155,7 +173,7 @@ 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}", 3));
+    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_x(zh, "@attr 1=1 @attr 2=103 {x my}", 0, 114));
 
@@ -221,6 +239,9 @@ static void tst(int argc, char **argv)
 
     /* exl=1 distance=2 order=0 relation=3 (=), known, unit=word */
     YAZ_CHECK(tl_query(zh, "@attr 1=4 @prox 1 2 1 3 k 2 my x", 1));
+    
+    /* 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));
 
     /* Non-indexed numeric use, but specified in bib1.att (bug #1142) */
     YAZ_CHECK(tl_query_x(zh, "@attr 1=1000 x", 0, 114));
@@ -313,7 +334,19 @@ static void tst(int argc, char **argv)
     /* N=41 and N=49 get only rec2 */
     YAZ_CHECK(tl_query(zh, "@attr 2=3 @attr gils 1=2040 @attr 4=109 \"41 49\" ", 1));
 
+
+    /* = */
+    YAZ_CHECK(tl_query(zh, "@attr 1=30 @attr 4=5 @attr 2=3 {2107-09-19 00:00:00}", 1));
+    /* < */
+    YAZ_CHECK(tl_query(zh, "@attr 1=30 @attr 4=5 @attr 2=1 {2107-09-19 00:00:00}", 0));
+    /* <= */
+    YAZ_CHECK(tl_query(zh, "@attr 1=30 @attr 4=5 @attr 2=2 {2107-09-19 00:00:00}", 1));
+    /* >= */
+    YAZ_CHECK(tl_query(zh, "@attr 1=30 @attr 4=5 @attr 2=4 {2107-09-19 00:00:00}", 1));
+    /* > */
+    YAZ_CHECK(tl_query(zh, "@attr 1=30 @attr 4=5 @attr 2=5 {2107-09-19 00:00:00}", 0));
     
+
     YAZ_CHECK(tl_close_down(zh, zs));
 }
 
@@ -322,6 +355,7 @@ TL_MAIN
 /*
  * Local variables:
  * c-basic-offset: 4
+ * c-file-style: "Stroustrup"
  * indent-tabs-mode: nil
  * End:
  * vim: shiftwidth=4 tabstop=8 expandtab