Fixed bug #1142: Non-indexed but listed attributes issues diagnostic.
authorAdam Dickmeiss <adam@indexdata.dk>
Fri, 25 May 2007 12:17:11 +0000 (12:17 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Fri, 25 May 2007 12:17:11 +0000 (12:17 +0000)
We keep the existing behavior by default and continue to issue a
diagnostic. Typically there are many attributes given in .att-files which
are never used in a Zebra installation. If they issue 0 hits, then
most Zebra servers will basically lie about their capabilities. It
would also confuse a lot of users.. (Dead programs tell no lies).
But it is certainly useful to be able to say "allow unknown use
attribtute" in controlled environments and in multi server systems
(where attributes may not indexed in all places) . Zebra now allows
attribute 14 to control this. 14=0 makes Zebra works as usual (throw
a diagnostic). 14=1 makes Zebra produce 0 hits (for the leaf/APT)

NEWS
doc/querymodel.xml
index/attribute.c
test/api/t5.c
util/su_codec.c

diff --git a/NEWS b/NEWS
index ca06c91..3c49c07 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,5 @@
+Fixed bug #1142: Non-indexed but listed attributes issues diagnostic.
+
 Fixed bug #1132: Missing value-of data in DOM filter.
 
 Fixed bug #1049: zebra.cfg lines with leading space are ignored.
index 0272966..da2844c 100644 (file)
@@ -1,5 +1,5 @@
  <chapter id="querymodel">
-  <!-- $Id: querymodel.xml,v 1.32 2007-05-24 13:44:09 adam Exp $ -->
+  <!-- $Id: querymodel.xml,v 1.33 2007-05-25 12:17:11 adam Exp $ -->
   <title>Query Model</title>
   
   <section id="querymodel-overview">
          <entry><literal>bib-1</literal></entry>
          <entry>Standard &acro.pqf; query language attribute set which defines the
           semantics of &acro.z3950; searching. In addition, all of the
-          non-use attributes (types 2-12) define the hard-wired 
+          non-use attributes (types 2-14) define the hard-wired 
           &zebra; internal query
           processing.</entry>
          <entry>default</entry>
        <entry>search</entry>
        <entry>2.0.8</entry>
        </row>
-      </tbody>
        <row>
        <entry>Maximum number of truncated terms (truncmax)</entry>
        <entry>13</entry>
        <entry>search</entry>
        <entry>2.0.10</entry>
        </row>
+       <row>
+       <entry>
+        Specifies whether un-indexed fields should be ignored.
+        A zero value (default) throws a diagnostic when an un-indexed
+        field is specified. A non-zero value makes it return 0 hits.
+       </entry>
+       <entry>14</entry>
+       <entry>search</entry>
+       <entry>2.0.16</entry>
+       </row>
+      </tbody>
      </tgroup>
     </table>      
     
        <row>
         <entry>numeric (@attr 4=109)</entry>
         <entry>ignored</entry>
-        <entry>Numeric ('u')</entry>
+        <entry>Numeric ('n')</entry>
         <entry>Special index for digital numbers</entry>
        </row>
        <row>
index 4272aab..fc78955 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: attribute.c,v 1.31 2007-05-08 12:50:04 adam Exp $
+/* $Id: attribute.c,v 1.32 2007-05-25 12:17:11 adam Exp $
    Copyright (C) 1995-2007
    Index Data ApS
 
@@ -98,7 +98,7 @@ ZEBRA_RES zebra_attr_list_get_ord(ZebraHandle zh,
         }
         if (r == -1)
         {
-            zebra_setError_zint(zh, YAZ_BIB1_UNSUPP_USE_ATTRIBUTE,  use_value);
+            zebra_setError_zint(zh, YAZ_BIB1_UNSUPP_USE_ATTRIBUTE, use_value);
             return ZEBRA_FAIL;
         }
     }
@@ -111,11 +111,23 @@ ZEBRA_RES zebra_attr_list_get_ord(ZebraHandle zh,
                                         index_type, use_string);
     if (*ord == -1)
     {
-        if (use_value < 0)
-            zebra_setError(zh, YAZ_BIB1_UNSUPP_USE_ATTRIBUTE, use_string);
-        else
-            zebra_setError_zint(zh, YAZ_BIB1_UNSUPP_USE_ATTRIBUTE, use_value);
-        return ZEBRA_FAIL;
+        /* attribute 14=1 does not issue a diagnostic even 
+           1) the attribute is numeric but listed in .att 
+           2) the use attribute is string
+        */
+        AttrType unsup;
+        int unsup_value = 0;
+        attr_init_AttrList(&unsup, attr_list, 14);
+        unsup_value = attr_find(&unsup, 0);
+
+        if (unsup_value != 1)
+        {
+            if (use_value < 0)
+                zebra_setError(zh, YAZ_BIB1_UNSUPP_USE_ATTRIBUTE, use_string);
+            else
+                zebra_setError_zint(zh, YAZ_BIB1_UNSUPP_USE_ATTRIBUTE, use_value);
+            return ZEBRA_FAIL;
+        }
     }
     return ZEBRA_OK;
 }
index 8f56878..9199b73 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: t5.c,v 1.22 2007-05-14 13:21:32 adam Exp $
+/* $Id: t5.c,v 1.23 2007-05-25 12:17:11 adam Exp $
    Copyright (C) 1995-2007
    Index Data ApS
 
@@ -189,6 +189,18 @@ 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));
 
+    /* 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));
+    YAZ_CHECK(tl_query_x(zh, "@attr 1=1000 @attr 14=1 x", 0, 0));
+    /* Non-indexed numeric use and unspecified in bib1.att */
+    YAZ_CHECK(tl_query_x(zh, "@attr 1=999 x", 0, 114));
+    YAZ_CHECK(tl_query_x(zh, "@attr 1=999 @attr 14=1 x", 0, 114));
+    /* Non-indexed string use attribute */
+    YAZ_CHECK(tl_query_x(zh, "@attr 1=gyf  x", 0, 114));
+    YAZ_CHECK(tl_query_x(zh, "@attr 1=gyf @attr 14=0 x", 0, 114));
+    YAZ_CHECK(tl_query_x(zh, "@attr 1=gyf @attr 14=1 x", 0, 0));
+
     /* provoke unsupported use attribute */
     YAZ_CHECK(tl_query_x(zh, "@attr 1=999 @attr 4=1 x", 0, 114));
     YAZ_CHECK(tl_query_x(zh, "@attr 1=999 @attr 4=6 x", 0, 114));
index f249468..cd9584a 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: su_codec.c,v 1.2 2007-01-15 15:10:26 adam Exp $
+/* $Id: su_codec.c,v 1.3 2007-05-25 12:17:12 adam Exp $
    Copyright (C) 1995-2007
    Index Data ApS
 
@@ -31,6 +31,14 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 int key_SU_encode (int ch, char *out)
 {
     int i;
+
+    if (ch == -1)
+    {
+        /* unique value .. which is different from ch >= 0 case */
+        /* is used to generate queries with "null" hits, bug #1142 */
+        out[0] = 129;
+        return 1;
+    }
     for (i = 0; ch; i++)
     {
        if (ch >= 64)