From: Adam Dickmeiss Date: Fri, 25 May 2007 12:17:11 +0000 (+0000) Subject: Fixed bug #1142: Non-indexed but listed attributes issues diagnostic. X-Git-Tag: ZEBRA.2.0.16~35 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=3f837255e2e97bd39ffabb13621d398f5610348c;p=idzebra-moved-to-github.git Fixed bug #1142: Non-indexed but listed attributes issues diagnostic. 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) --- diff --git a/NEWS b/NEWS index ca06c91..3c49c07 100644 --- 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. diff --git a/doc/querymodel.xml b/doc/querymodel.xml index 0272966..da2844c 100644 --- a/doc/querymodel.xml +++ b/doc/querymodel.xml @@ -1,5 +1,5 @@ - + Query Model
@@ -205,7 +205,7 @@ bib-1 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. default @@ -1531,13 +1531,23 @@ search 2.0.8 - Maximum number of truncated terms (truncmax) 13 search 2.0.10 + + + 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. + + 14 + search + 2.0.16 + + @@ -2172,7 +2182,7 @@ numeric (@attr 4=109) ignored - Numeric ('u') + Numeric ('n') Special index for digital numbers diff --git a/index/attribute.c b/index/attribute.c index 4272aab..fc78955 100644 --- a/index/attribute.c +++ b/index/attribute.c @@ -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; } diff --git a/test/api/t5.c b/test/api/t5.c index 8f56878..9199b73 100644 --- a/test/api/t5.c +++ b/test/api/t5.c @@ -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)); diff --git a/util/su_codec.c b/util/su_codec.c index f249468..cd9584a 100644 --- a/util/su_codec.c +++ b/util/su_codec.c @@ -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)