Fixed alwaysmatches searches for ICU.
authorAdam Dickmeiss <adam@indexdata.dk>
Wed, 9 Apr 2008 10:51:42 +0000 (12:51 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Wed, 9 Apr 2008 10:51:42 +0000 (12:51 +0200)
This commit fixes the alwaysmatches including _ALLRECORDS for ICU term
indexing. Bug #2139.

index/rpnsearch.c
test/api/t17.c
test/api/t5.c

index a8cc61d..ec341d1 100644 (file)
@@ -1035,28 +1035,45 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
 
     if (zebra_maps_is_icu(zm))
     {
-        /* ICU case */
-        switch (truncation_value)
+        int relation_value;
+        AttrType relation;
+        
+        attr_init_APT(&relation, zapt, 2);
+        relation_value = attr_find(&relation, NULL);
+        if (relation_value == 103) /* always matches */
+            termp += strlen(termp); /* move to end of term */
+        else if (relation_value == 3 || relation_value == 102 || relation_value == -1)
         {
-        case -1:         /* not specified */
-        case 100:        /* do not truncate */
-            if (!term_100_icu(zm, &termp, term_dict, space_split, display_term, 0))
+            /* ICU case */
+            switch (truncation_value)
             {
-                *term_sub = 0;
-                return ZEBRA_OK;
-            }
-            break;
-        case 1:          /* right truncation */
-            if (!term_100_icu(zm, &termp, term_dict, space_split, display_term, 1))
-            {
-                *term_sub = 0;
-                return ZEBRA_OK;
+            case -1:         /* not specified */
+            case 100:        /* do not truncate */
+                if (!term_100_icu(zm, &termp, term_dict, space_split, display_term, 0))
+                {
+                    *term_sub = 0;
+                    return ZEBRA_OK;
+                }
+                break;
+            case 1:          /* right truncation */
+                if (!term_100_icu(zm, &termp, term_dict, space_split, display_term, 1))
+                {
+                    *term_sub = 0;
+                    return ZEBRA_OK;
+                }
+                break;
+            default:
+                zebra_setError_zint(zh,
+                                    YAZ_BIB1_UNSUPP_TRUNCATION_ATTRIBUTE,
+                                    truncation_value);
+                return ZEBRA_FAIL;
             }
-            break;
-        default:
+        }
+        else
+        {
             zebra_setError_zint(zh,
-                                YAZ_BIB1_UNSUPP_TRUNCATION_ATTRIBUTE,
-                                truncation_value);
+                                YAZ_BIB1_UNSUPP_RELATION_ATTRIBUTE,
+                                relation_value);
             return ZEBRA_FAIL;
         }
     }
index c20c99b..1c1cc3c 100644 (file)
@@ -101,6 +101,12 @@ static void tst(int argc, char **argv)
     /* complete-subfield search */
     YAZ_CHECK(tl_query(zh, "@attr 1=title @attr 6=2 {my computer}", 1));
     YAZ_CHECK(tl_query(zh, "@attr 1=title @attr 6=2 {my}", 0));
+
+    /* always matches */
+    YAZ_CHECK(tl_query(zh, "@attr 1=_ALLRECORDS @attr 2=103 {}", 5));
+    YAZ_CHECK(tl_query(zh, "@attr 1=title @attr 2=103 {}", 5));
+    YAZ_CHECK(tl_query(zh, "@attr 1=abstract @attr 2=103 {}", 1));
+    YAZ_CHECK(tl_query(zh, "@attr 1=abstract @attr 2=103 {does not match}", 1));
     
     /* scan */
     {   /* word search */
index 23c4301..25663b4 100644 (file)
@@ -124,6 +124,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=4 @attr 2=103 {x my}", 3));
     YAZ_CHECK(tl_query_x(zh, "@attr 1=1 @attr 2=103 {x my}", 0, 114));