X-Git-Url: http://git.indexdata.com/?p=idzebra-moved-to-github.git;a=blobdiff_plain;f=index%2Fattribute.c;h=9e8f327581d662cbabca6df2298e31ed7414eb52;hp=10b1e6d968c69ee4e2416a327d7b729f7080d3ff;hb=4478d785b7769691261005c98063b98a5a5971b3;hpb=6ba9698e88c0283e40fa5980a1a6b551fff2d597 diff --git a/index/attribute.c b/index/attribute.c index 10b1e6d..9e8f327 100644 --- a/index/attribute.c +++ b/index/attribute.c @@ -1,4 +1,4 @@ -/* $Id: attribute.c,v 1.23 2006-05-19 13:49:34 adam Exp $ +/* $Id: attribute.c,v 1.26 2006-08-14 10:40:15 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -15,9 +15,9 @@ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Zebra; see the file LICENSE.zebra. If not, write to the -Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ #include @@ -67,6 +67,7 @@ static int att_getentbyatt(ZebraHandle zi, oid_value set, int att, ZEBRA_RES zebra_attr_list_get_ord(ZebraHandle zh, Z_AttributeList *attr_list, + zinfo_index_category_t cat, int index_type, oid_value curAttributeSet, int *ord) @@ -105,7 +106,8 @@ ZEBRA_RES zebra_attr_list_get_ord(ZebraHandle zh, zebra_setError(zh, YAZ_BIB1_UNSUPP_USE_ATTRIBUTE, 0); return ZEBRA_FAIL; } - *ord = zebraExplain_lookup_attr_str(zh->reg->zei, index_type, use_string); + *ord = zebraExplain_lookup_attr_str(zh->reg->zei, cat, + index_type, use_string); if (*ord == -1) { if (use_value < 0) @@ -124,27 +126,52 @@ ZEBRA_RES zebra_apt_get_ord(ZebraHandle zh, oid_value curAttributeSet, int *ord) { + ZEBRA_RES res = ZEBRA_OK; + AttrType relation; + int relation_value; + zinfo_index_category_t cat = zinfo_index_category_index; + + attr_init_APT(&relation, zapt, 2); + relation_value = attr_find(&relation, NULL); + + if (relation_value == 103) /* always matches */ + cat = zinfo_index_category_alwaysmatches; + if (!xpath_use) - return zebra_attr_list_get_ord(zh, zapt->attributes, - index_type, curAttributeSet, ord); + { + res = zebra_attr_list_get_ord(zh, zapt->attributes, + cat, index_type, + curAttributeSet, ord); + /* use attribute not found. But it the relation is + always matches and the regulare index attribute is found + return a different diagnostic */ + if (res != ZEBRA_OK && + relation_value == 103 + && zebra_attr_list_get_ord( + zh, zapt->attributes, + zinfo_index_category_index, index_type, + curAttributeSet, ord) == ZEBRA_OK) + zebra_setError_zint(zh, YAZ_BIB1_UNSUPP_RELATION_ATTRIBUTE, 103); + } else { - *ord = zebraExplain_lookup_attr_str(zh->reg->zei, index_type, + *ord = zebraExplain_lookup_attr_str(zh->reg->zei, cat, index_type, xpath_use); if (*ord == -1) { yaz_log(YLOG_LOG, "zebra_apt_get_ord FAILED xpath=%s index_type=%c", xpath_use, index_type); zebra_setError(zh, YAZ_BIB1_UNSUPP_USE_ATTRIBUTE, 0); - return ZEBRA_FAIL; + res = ZEBRA_FAIL; } else { yaz_log(YLOG_LOG, "zebra_apt_get_ord OK xpath=%s index_type=%c", xpath_use, index_type); + } - return ZEBRA_OK; } + return res; } ZEBRA_RES zebra_sort_get_ord(ZebraHandle zh, @@ -162,9 +189,11 @@ ZEBRA_RES zebra_sort_get_ord(ZebraHandle zh, *numerical = 1; if (zebra_attr_list_get_ord(zh, sortAttributes->list, + zinfo_index_category_sort, 's', VAL_BIB1, ord)== ZEBRA_OK) return ZEBRA_OK; if (zebra_attr_list_get_ord(zh, sortAttributes->list, + zinfo_index_category_sort, 'S', VAL_BIB1, ord)== ZEBRA_OK) return ZEBRA_OK; return ZEBRA_FAIL;