+Zebra uses string attributes for indexing internally. Using set+numeric
+use attribute can still be used. But that is a search-only conversion which
+inspects .att-set files as indicated using attset-directives in zebra.cfg.
+attset references are no longer required, but when used they deserve
+as "check" for that the index names used are also present in .att.
+
Implemented bug #588: allrecords search. Using @attr 1=allrecords ""
matches all records in a database.
-/* $Id: d1_absyn.c,v 1.24 2006-05-10 08:13:17 adam Exp $
- Copyright (C) 1995-2005
+/* $Id: d1_absyn.c,v 1.25 2006-05-19 13:49:33 adam Exp $
+ Copyright (C) 1995-2006
Index Data ApS
This file is part of the Zebra server.
#include <yaz/log.h>
#include <yaz/oid.h>
#include <idzebra/data1.h>
+#include <idzebra/recctrl.h>
#include <zebra_xpath.h>
#include <d1_absyn.h>
return res;
}
-/* *ostrich*
-
- added arg xpelement... when called from xelm context, it's 1, saying
- that ! means xpath, not element name as attribute name...
-
- pop, 2002-12-13
- */
-static int parse_termlists (data1_handle dh, data1_termlist ***tpp,
- char *cp, const char *file, int lineno,
- const char *element_name, data1_absyn *res,
- int xpelement)
+static int parse_termlists(data1_handle dh, data1_termlist ***tpp,
+ char *cp, const char *file, int lineno,
+ const char *element_name, data1_absyn *res,
+ int xpelement,
+ data1_attset *attset)
{
data1_termlist **tp = *tpp;
while(1)
nmem_malloc(data1_nmem_get(dh), sizeof(**tp));
(*tp)->next = 0;
-#if NATTR
- (*tp)->index_name = nmem_strdup(data1_nmem_get(dh), element_name);
- if (*attname == '!' && xpelement)
- (*tp)->index_name = 0;
-#else
- if (!xpelement) {
- if (*attname == '!')
+ if (*attname == '!')
+ {
+ if (!xpelement && element_name)
strcpy(attname, element_name);
- }
- if (!((*tp)->att = data1_getattbyname(dh, res->attset, attname)))
- {
- if ((!xpelement) || (*attname != '!')) {
- yaz_log(YLOG_WARN,
- "%s:%d: Couldn't find att '%s' in attset",
- file, lineno, attname);
- return -1;
- } else {
- (*tp)->att = 0;
+ else if (xpelement)
+ strcpy(attname, ZEBRA_XPATH_CDATA);
+ }
+ if (attset)
+ {
+ if (!data1_getattbyname(dh, attset, attname))
+ {
+ yaz_log(YLOG_WARN, "Index '%s' not found in attset(s)",
+ attname);
}
- }
-#endif
+ }
+
+ (*tp)->index_name = nmem_strdup(data1_nmem_get(dh), attname);
+ assert (*(*tp)->index_name != '!');
if (r == 2 && (source = strchr(structure, ':')))
*source++ = '\0'; /* cut off structure .. */
else
{
data1_sub_elements *cur_elements = NULL;
data1_xpelement *cur_xpelement = NULL;
+ data1_attset *attset_list = data1_empty_attset(dh);
+ data1_attset_child **attset_childp = &attset_list->children;
data1_absyn *res = 0;
FILE *f;
data1_maptab **maptabp;
data1_marctab **marcp;
data1_termlist *all = 0;
- data1_attset_child **attset_childp;
data1_tagset **tagset_childp;
struct data1_systag **systagsp;
int level = 0;
systagsp = &res->systags;
tagset_childp = &res->tagset;
- res->attset = data1_empty_attset (dh);
- attset_childp = &res->attset->children;
-
res->varset = 0;
res->esetnames = 0;
esetpp = &res->esetnames;
res->sub_elements = NULL;
res->main_elements = NULL;
res->xp_elements = NULL;
-
+
while (f && (argc = read_absyn_line(f, &lineno, line, 512, argv, 50)))
{
char *cmd = *argv;
p = termlists;
if (*p != '-')
{
- assert (res->attset);
-
- if (parse_termlists (dh, &tp, p, file, lineno, name, res, 0))
+ if (parse_termlists (dh, &tp, p, file, lineno, name, res, 0,
+ attset_list))
{
fclose (f);
return 0;
p = termlists;
if (*p != '-')
{
- assert (res->attset);
-
if (parse_termlists (dh, &tp, p, file, lineno,
- xpath_expr, res, 1))
+ xpath_expr, res, 1, attset_list))
{
fclose (f);
return 0;
file, lineno);
continue;
}
- if (parse_termlists (dh, &tp, argv[1], file, lineno, 0, res, 0))
+ if (parse_termlists (dh, &tp, argv[1], file, lineno, 0, res, 0,
+ attset_list))
{
fclose (f);
return 0;
}
else if (!strcmp(cmd, "attset"))
{
-#if NATTR
- yaz_log(YLOG_WARN, "%s:%d: attset obsolete", file, lineno);
-#else
- char *name;
- data1_attset *attset;
-
- if (argc != 2)
- {
- yaz_log(YLOG_WARN, "%s:%d: Bad # of args to attset",
- file, lineno);
- continue;
- }
- name = argv[1];
- if (!(attset = data1_get_attset (dh, name)))
- {
- yaz_log(YLOG_WARN, "%s:%d: Couldn't find attset %s",
- file, lineno, name);
- continue;
- }
- *attset_childp = (data1_attset_child *)
- nmem_malloc (data1_nmem_get(dh), sizeof(**attset_childp));
- (*attset_childp)->child = attset;
- (*attset_childp)->next = 0;
- attset_childp = &(*attset_childp)->next;
-#endif
+ char *name;
+ data1_attset *attset;
+
+ if (argc != 2)
+ {
+ yaz_log(YLOG_WARN, "%s:%d: Bad # of args to attset",
+ file, lineno);
+ continue;
+ }
+ name = argv[1];
+ if (!(attset = data1_get_attset (dh, name)))
+ {
+ yaz_log(YLOG_WARN, "%s:%d: Couldn't find attset %s",
+ file, lineno, name);
+ continue;
+ }
+ *attset_childp = (data1_attset_child *)
+ nmem_malloc (data1_nmem_get(dh), sizeof(**attset_childp));
+ (*attset_childp)->child = attset;
+ (*attset_childp)->next = 0;
+ attset_childp = &(*attset_childp)->next;
}
else if (!strcmp(cmd, "tagset"))
{
-/* $Id: d1_attset.c,v 1.8 2006-05-10 08:13:18 adam Exp $
- Copyright (C) 1995-2005
+/* $Id: d1_attset.c,v 1.9 2006-05-19 13:49:33 adam Exp $
+ Copyright (C) 1995-2006
Index Data ApS
This file is part of the Zebra server.
#include <yaz/log.h>
#include <idzebra/data1.h>
-data1_att *data1_getattbyname(data1_handle dh, data1_attset *s, char *name)
+data1_att *data1_getattbyname(data1_handle dh, data1_attset *s, const char *name)
{
data1_att *r;
data1_attset_child *c;
/* scan local set */
for (r = s->atts; r; r = r->next)
- if (!data1_matchstr(r->name, name))
- return r;
+ if (!data1_matchstr(r->name, name))
+ return r;
for (c = s->children; c; c = c->next)
{
- assert (c->child);
- /* scan included sets */
- if ((r = data1_getattbyname (dh, c->child, name)))
- return r;
+ assert (c->child);
+ /* scan included sets */
+ if ((r = data1_getattbyname (dh, c->child, name)))
+ return r;
}
return 0;
}
-# $Id: Makefile.am,v 1.22 2005-03-30 09:25:23 adam Exp $
+# $Id: Makefile.am,v 1.23 2006-05-19 13:49:33 adam Exp $
noinst_HEADERS = bset.h charmap.h \
direntz.h passwddb.h dfa.h zebra_xpath.h d1_absyn.h \
-rset.h dfaset.h sortidx.h zebra-lock.h
+rset.h dfaset.h sortidx.h zebra-lock.h attrfind.h
SUBDIRS = idzebra
--- /dev/null
+/* $Id: attrfind.h,v 1.1 2006-05-19 13:49:34 adam Exp $
+ Copyright (C) 2005-2006
+ Index Data ApS
+
+This file is part of the Zebra server.
+
+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
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+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.
+*/
+
+#ifndef ATTRFIND_H
+#define ATTRFIND_H
+
+#include <yaz/yconfig.h>
+#include <yaz/z-core.h>
+#include <yaz/oid.h>
+
+YAZ_BEGIN_CDECL
+
+typedef struct {
+ int type;
+ int major;
+ int minor;
+ Z_AttributeElement **attributeList;
+ int num_attributes;
+} AttrType;
+
+void attr_init_APT(AttrType *src, Z_AttributesPlusTerm *zapt, int type);
+
+void attr_init_AttrList(AttrType *src, Z_AttributeList *list, int type);
+
+int attr_find_ex(AttrType *src, oid_value *attributeSetP,
+ const char **string_value);
+int attr_find(AttrType *src, oid_value *attributeSetP);
+
+
+YAZ_END_CDECL
+
+#endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
-/* $Id: d1_absyn.h,v 1.3 2006-05-10 08:13:18 adam Exp $
- Copyright (C) 1995-2005
+/* $Id: d1_absyn.h,v 1.4 2006-05-19 13:49:34 adam Exp $
+ Copyright (C) 1995-2006
Index Data ApS
This file is part of the Zebra server.
char *name;
oid_value reference;
data1_tagset *tagset;
- data1_attset *attset;
data1_varset *varset;
data1_esetname *esetnames;
data1_maptab *maptabs;
-/* $Id: data1.h,v 1.12 2006-05-10 08:13:20 adam Exp $
- Copyright (C) 1995-2005
+/* $Id: data1.h,v 1.13 2006-05-19 13:49:34 adam Exp $
+ Copyright (C) 1995-2006
Index Data ApS
This file is part of the Zebra server.
typedef struct data1_handle_info *data1_handle;
YAZ_EXPORT data1_att *data1_getattbyname(data1_handle dh, data1_attset *s,
- char *name);
+ const char *name);
YAZ_EXPORT data1_attset *data1_read_attset(data1_handle dh, const char *file);
YAZ_EXPORT data1_attset *data1_empty_attset(data1_handle dh);
typedef struct data1_termlist
{
-#if NATTR
char *index_name;
-#else
- data1_att *att;
-#endif
char *structure;
char *source;
struct data1_termlist *next;
-/* $Id: recctrl.h,v 1.19 2006-05-10 08:13:20 adam Exp $
+/* $Id: recctrl.h,v 1.20 2006-05-19 13:49:34 adam Exp $
Copyright (C) 1995-2006
Index Data ApS
YAZ_BEGIN_CDECL
-#if NATTR
+/* 1 */
#define ZEBRA_XPATH_ELM_BEGIN "_XPATH_BEGIN"
+
+/* 2 */
#define ZEBRA_XPATH_ELM_END "_XPATH_END"
+
+/* 1016 */
#define ZEBRA_XPATH_CDATA "_XPATH_CDATA"
-#define ZEBRA_XPATH_ATTR "_XPATH_ATTR"
-#endif
+
+/* 3 */
+#define ZEBRA_XPATH_ATTR_NAME "_XPATH_ATTR_NAME"
+
+/* 1015 */
+#define ZEBRA_XPATH_ATTR_CDATA "_XPATH_ATTR_CDATA"
/* single word entity */
typedef struct {
-#if NATTR
-#else
- int attrSet;
- int attrUse;
-#endif
unsigned index_type;
const char *index_name;
const char *term_buf;
-/* $Id: util.h,v 1.6 2006-05-10 08:13:20 adam Exp $
+/* $Id: util.h,v 1.7 2006-05-19 13:49:34 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
#define CAST_ZINT_TO_INT(x) (int)(x)
#define CAST_ZINT_TO_DOUBLE(x) (double)(x)
-/* NATTR=1 for string-attribute architecture, =0 for set+use . */
-#define NATTR 0
-
#endif
/*
* Local variables:
-/* $Id: attribute.c,v 1.22 2006-05-10 08:13:20 adam Exp $
- Copyright (C) 1995-2005
+/* $Id: attribute.c,v 1.23 2006-05-19 13:49:34 adam Exp $
+ Copyright (C) 1995-2006
Index Data ApS
This file is part of the Zebra server.
#include <stdio.h>
#include <yaz/log.h>
+#include <yaz/diagbib1.h>
#include <idzebra/res.h>
#include <idzebra/util.h>
+#include <attrfind.h>
#include "index.h"
-static data1_att *getatt(data1_attset *p, int att, const char *sattr)
+static data1_att *getatt(data1_attset *p, int att)
{
data1_att *a;
data1_attset_child *c;
/* scan local set */
for (a = p->atts; a; a = a->next)
- if (sattr && !yaz_matchstr(sattr, a->name))
- return a;
- else if (a->value == att)
+ if (a->value == att)
return a;
/* scan included sets */
for (c = p->children; c; c = c->next)
- if ((a = getatt(c->child, att, sattr)))
+ if ((a = getatt(c->child, att)))
return a;
return 0;
}
-int att_getentbyatt(ZebraHandle zi, attent *res, oid_value set, int att,
- const char *sattr)
+static int att_getentbyatt(ZebraHandle zi, oid_value set, int att,
+ const char **name)
{
data1_att *r;
data1_attset *p;
p = data1_attset_search_id (zi->reg->dh, set);
}
if (!p) /* set undefined */
- {
- if (sattr)
- return -1; /* return bad string attribute */
- else
- return -2; /* return bad set */
- }
- if (!(r = getatt(p, att, sattr)))
+ return -2;
+ if (!(r = getatt(p, att)))
return -1;
- res->attset_ordinal = r->parent->reference;
- res->local_attributes = r->locals;
+ *name = r->name;
return 0;
}
+
+
+ZEBRA_RES zebra_attr_list_get_ord(ZebraHandle zh,
+ Z_AttributeList *attr_list,
+ int index_type,
+ oid_value curAttributeSet,
+ int *ord)
+{
+ int use_value = -1;
+ const char *use_string = 0;
+ AttrType use;
+
+ attr_init_AttrList(&use, attr_list, 1);
+ use_value = attr_find_ex(&use, &curAttributeSet, &use_string);
+
+ if (use_value < 0)
+ {
+ if (!use_string)
+ use_string = "any";
+ }
+ else
+ {
+ /* we have a use attribute and attribute set */
+ int r;
+
+ r = att_getentbyatt(zh, curAttributeSet, use_value, &use_string);
+ if (r == -2)
+ {
+ zebra_setError_zint(zh, YAZ_BIB1_UNSUPP_ATTRIBUTE_SET, 0);
+ return ZEBRA_FAIL;
+ }
+ if (r == -1)
+ {
+ zebra_setError_zint(zh, YAZ_BIB1_UNSUPP_USE_ATTRIBUTE, use_value);
+ return ZEBRA_FAIL;
+ }
+ }
+ if (!use_string)
+ {
+ zebra_setError(zh, YAZ_BIB1_UNSUPP_USE_ATTRIBUTE, 0);
+ return ZEBRA_FAIL;
+ }
+ *ord = zebraExplain_lookup_attr_str(zh->reg->zei, 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;
+ }
+ return ZEBRA_OK;
+}
+
+ZEBRA_RES zebra_apt_get_ord(ZebraHandle zh,
+ Z_AttributesPlusTerm *zapt,
+ int index_type,
+ const char *xpath_use,
+ oid_value curAttributeSet,
+ int *ord)
+{
+ if (!xpath_use)
+ return zebra_attr_list_get_ord(zh, zapt->attributes,
+ index_type, curAttributeSet, ord);
+ else
+ {
+ *ord = zebraExplain_lookup_attr_str(zh->reg->zei, 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;
+ }
+ else
+ {
+ yaz_log(YLOG_LOG, "zebra_apt_get_ord OK xpath=%s index_type=%c",
+ xpath_use, index_type);
+ }
+ return ZEBRA_OK;
+ }
+}
+
+ZEBRA_RES zebra_sort_get_ord(ZebraHandle zh,
+ Z_SortAttributes *sortAttributes,
+ int *ord,
+ int *numerical)
+{
+ AttrType structure;
+ int structure_value;
+ attr_init_AttrList(&structure, sortAttributes->list, 4);
+
+ *numerical = 0;
+ structure_value = attr_find(&structure, 0);
+ if (structure_value == 109)
+ *numerical = 1;
+
+ if (zebra_attr_list_get_ord(zh, sortAttributes->list,
+ 's', VAL_BIB1, ord)== ZEBRA_OK)
+ return ZEBRA_OK;
+ if (zebra_attr_list_get_ord(zh, sortAttributes->list,
+ 'S', VAL_BIB1, ord)== ZEBRA_OK)
+ return ZEBRA_OK;
+ return ZEBRA_FAIL;
+}
+
+
/*
* Local variables:
* c-basic-offset: 4
-/* $Id: extract.c,v 1.214 2006-05-18 12:03:05 adam Exp $
+/* $Id: extract.c,v 1.215 2006-05-19 13:49:34 adam Exp $
Copyright (C) 1995-2006
Index Data ApS
{
w->zebra_maps = p->zebra_maps;
w->seqno = 1;
-#if NATTR
-#else
- w->attrSet = VAL_BIB1;
- w->attrUse = 1016;
-#endif
- w->index_name = 0;
+ w->index_name = "any";
w->index_type = 'w';
w->extractCtrl = p;
w->record_id = 0;
static void searchRecordKey(ZebraHandle zh,
zebra_rec_keys_t reckeys,
- int attrSetS, int attrUseS,
+ const char *index_name,
const char **ws, int ws_length)
{
int i;
- int ch;
+ int ch = -1;
for (i = 0; i<ws_length; i++)
ws[i] = NULL;
- ch = zebraExplain_lookup_attr_su_any_index(zh->reg->zei,
- attrSetS, attrUseS);
+ if (ch < 0)
+ ch = zebraExplain_lookup_attr_str(zh->reg->zei, '0', index_name);
+ if (ch < 0)
+ ch = zebraExplain_lookup_attr_str(zh->reg->zei, 'p', index_name);
+ if (ch < 0)
+ ch = zebraExplain_lookup_attr_str(zh->reg->zei, 'w', index_name);
+
if (ch < 0)
return ;
{
const char *ws[32];
char attset_str[64], attname_str[64];
- data1_attset *attset;
int i;
- int attSet = 1, attUse = 1;
int first = 1;
for (s++; strchr(FILE_MATCH_BLANK, *s); s++)
for (; strchr(FILE_MATCH_BLANK, *s); s++)
;
- if (*s == ',')
+ if (*s != ',')
+ strcpy(attname_str, attset_str);
+ else
{
for (s++; strchr(FILE_MATCH_BLANK, *s); s++)
;
attname_str[i++] = *s;
attname_str[i] = '\0';
}
-
- if ((attset = data1_get_attset (zh->reg->dh, attset_str)))
- {
- data1_att *att;
- attSet = attset->reference;
- att = data1_getattbyname(zh->reg->dh, attset, attname_str);
- if (att)
- attUse = att->value;
- else
- attUse = atoi (attname_str);
- }
- searchRecordKey (zh, reckeys, attSet, attUse, ws, 32);
+
+ searchRecordKey (zh, reckeys, attname_str, ws, 32);
if (*s != ')')
{
ZebraExplainInfo zei = zh->reg->zei;
int ch;
- if (p->index_name)
- {
- ch = zebraExplain_lookup_attr_str(zei, p->index_type, p->index_name);
- if (ch < 0)
- ch = zebraExplain_add_attr_str(zei, p->index_type, p->index_name);
- }
- else
- {
-#if NATTR
- return;
-#else
- ch = zebraExplain_lookup_attr_su(zei, p->index_type,
- p->attrSet, p->attrUse);
- if (ch < 0)
- ch = zebraExplain_add_attr_su(zei, p->index_type,
- p->attrSet, p->attrUse);
-#endif
- }
+ if (!p->index_name)
+ return;
+
+ ch = zebraExplain_lookup_attr_str(zei, p->index_type, p->index_name);
+ if (ch < 0)
+ ch = zebraExplain_add_attr_str(zei, p->index_type, p->index_name);
+
key.len = 4;
key.mem[0] = ch;
key.mem[1] = p->record_id;
ZebraExplainInfo zei = zh->reg->zei;
int ch;
- if (p->index_name)
- {
- ch = zebraExplain_lookup_attr_str(zei, p->index_type, p->index_name);
- if (ch < 0)
- ch = zebraExplain_add_attr_str(zei, p->index_type, p->index_name);
- }
- else
- {
-#if NATTR
- return;
-#else
- ch = zebraExplain_lookup_attr_su(zei, p->index_type,
- VAL_IDXPATH, p->attrUse);
- if (ch < 0)
- ch = zebraExplain_add_attr_su(zei, p->index_type,
- VAL_IDXPATH, p->attrUse);
-#endif
- }
+ if (!p->index_name)
+ return;
+
+ ch = zebraExplain_lookup_attr_str(zei, p->index_type, p->index_name);
+ if (ch < 0)
+ ch = zebraExplain_add_attr_str(zei, p->index_type, p->index_name);
key.len = 4;
key.mem[0] = ch;
key.mem[1] = p->record_id;
-/* $Id: index.h,v 1.161 2006-05-18 12:03:05 adam Exp $
+/* $Id: index.h,v 1.162 2006-05-19 13:49:34 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
void zebra_server_unlock (ZebraService zh, int commitPhase);
int zebra_server_lock_get_state (ZebraService zh, time_t *timep);
+#if 1
typedef struct attent
{
int attset_ordinal;
data1_local_attribute *local_attributes;
} attent;
-
-int att_getentbyatt(ZebraHandle zh, attent *res, oid_value set, int att,
- const char *sattr);
+#endif
int zebra_record_fetch (ZebraHandle zh, SYSNO sysno, int score,
zebra_snippets *hit_snippet, ODR stream,
void zebra_term_untrans(ZebraHandle zh, int reg_type,
char *dst, const char *src);
+ZEBRA_RES zebra_apt_get_ord(ZebraHandle zh,
+ Z_AttributesPlusTerm *zapt,
+ int index_type,
+ const char *xpath_use,
+ oid_value curAttributeSet,
+ int *ord);
+
+ZEBRA_RES zebra_attr_list_get_ord(ZebraHandle zh,
+ Z_AttributeList *attr_list,
+ int index_type,
+ oid_value curAttributeSet,
+ int *ord);
+
+ZEBRA_RES zebra_sort_get_ord(ZebraHandle zh,
+ Z_SortAttributes *sortAttributes,
+ int *ord,
+ int *numerical);
+
YAZ_END_CDECL
#endif
-/* $Id: zebrash.c,v 1.37 2006-05-10 08:13:23 adam Exp $
+/* $Id: zebrash.c,v 1.38 2006-05-19 13:49:34 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
0);
if (0==rc)
{
- wrbuf_printf(outbuff,"ok sysno=%d\n",sysno);
+ wrbuf_printf(outbuff,"ok sysno=" ZINT_FORMAT "\n",sysno);
}
return rc;
}
-/* $Id: zinfo.c,v 1.63 2006-05-18 12:03:05 adam Exp $
+/* $Id: zinfo.c,v 1.64 2006-05-19 13:49:34 adam Exp $
Copyright (C) 1995-2006
Index Data ApS
*zsui; zsui = &(*zsui)->next)
if ((*zsui)->info.index_type == index_type
&& (*zsui)->info.which == ZEB_SU_STR
- && !strcmp((*zsui)->info.u.str, str))
+ && !yaz_matchstr((*zsui)->info.u.str, str))
{
struct zebSUInfoB *zsui_this = *zsui;
{
struct zebSUInfoB *zsui = zebraExplain_add_sui_info(zei, index_type);
+ yaz_log(YLOG_WARN, "add_attr_su");
zebraExplain_addAttributeSet (zei, set);
zsui->info.which = ZEB_SU_SET_USE;
zsui->info.u.su.set = set;
-/* $Id: zrpn.c,v 1.213 2006-05-17 17:46:45 adam Exp $
+/* $Id: zrpn.c,v 1.214 2006-05-19 13:49:34 adam Exp $
Copyright (C) 1995-2006
Index Data ApS
#include <yaz/diagbib1.h>
#include "index.h"
#include <zebra_xpath.h>
-
+#include <attrfind.h>
#include <charmap.h>
#include <rset.h>
int reg_type;
};
-typedef struct
-{
- int type;
- int major;
- int minor;
- Z_AttributesPlusTerm *zapt;
-} AttrType;
-
static int log_level_set = 0;
static int log_level_rpn = 0;
dict_grep_cmap(reg->dict, map_info, rpn_char_map_handler);
}
-static int attr_find_ex(AttrType *src, oid_value *attributeSetP,
- const char **string_value)
-{
- int num_attributes;
-
- num_attributes = src->zapt->attributes->num_attributes;
- while (src->major < num_attributes)
- {
- Z_AttributeElement *element;
-
- element = src->zapt->attributes->attributes[src->major];
- if (src->type == *element->attributeType)
- {
- switch (element->which)
- {
- case Z_AttributeValue_numeric:
- ++(src->major);
- if (element->attributeSet && attributeSetP)
- {
- oident *attrset;
-
- attrset = oid_getentbyoid(element->attributeSet);
- *attributeSetP = attrset->value;
- }
- return *element->value.numeric;
- break;
- case Z_AttributeValue_complex:
- if (src->minor >= element->value.complex->num_list)
- break;
- if (element->attributeSet && attributeSetP)
- {
- oident *attrset;
-
- attrset = oid_getentbyoid(element->attributeSet);
- *attributeSetP = attrset->value;
- }
- if (element->value.complex->list[src->minor]->which ==
- Z_StringOrNumeric_numeric)
- {
- ++(src->minor);
- return
- *element->value.complex->list[src->minor-1]->u.numeric;
- }
- else if (element->value.complex->list[src->minor]->which ==
- Z_StringOrNumeric_string)
- {
- if (!string_value)
- break;
- ++(src->minor);
- *string_value =
- element->value.complex->list[src->minor-1]->u.string;
- return -2;
- }
- else
- break;
- default:
- assert(0);
- }
- }
- ++(src->major);
- }
- return -1;
-}
-
-static int attr_find(AttrType *src, oid_value *attributeSetP)
-{
- return attr_find_ex(src, attributeSetP, 0);
-}
-
-static void attr_init(AttrType *src, Z_AttributesPlusTerm *zapt,
- int type)
-{
- src->zapt = zapt;
- src->type = type;
- src->major = 0;
- src->minor = 0;
-}
-
#define TERM_COUNT
struct grep_info {
char *term_tmp = term_dict + strlen(term_dict);
char term_component[2*IT_MAX_WORD+20];
- attr_init(&relation, zapt, 2);
+ attr_init_APT(&relation, zapt, 2);
relation_value = attr_find(&relation, NULL);
*error_code = 0;
struct grep_info *grep_info,
int reg_type, int complete_flag,
int num_bases, char **basenames,
- char *term_dst, int xpath_use,
+ char *term_dst,
+ const char *xpath_use,
struct ord_list **ol);
static ZEBRA_RES term_limits_APT(ZebraHandle zh,
AttrType hits_limit_attr;
int term_ref_id_int;
- attr_init(&hits_limit_attr, zapt, 9);
+ attr_init_APT(&hits_limit_attr, zapt, 9);
*hits_limit_value = attr_find(&hits_limit_attr, NULL);
- attr_init(&term_ref_id_attr, zapt, 10);
+ attr_init_APT(&term_ref_id_attr, zapt, 10);
term_ref_id_int = attr_find_ex(&term_ref_id_attr, NULL, term_ref_id_str);
if (term_ref_id_int >= 0)
{
int reg_type, int complete_flag,
int num_bases, char **basenames,
char *term_dst,
- const char *rank_type, int xpath_use,
+ const char *rank_type,
+ const char *xpath_use,
NMEM rset_nmem,
RSET *rset,
struct rset_key_control *kc)
struct grep_info *grep_info,
int reg_type, int complete_flag,
int num_bases, char **basenames,
- char *term_dst, int xpath_use,
+ char *term_dst,
+ const char *xpath_use,
struct ord_list **ol)
{
char term_dict[2*IT_MAX_WORD+4000];
int j, r, base_no;
AttrType truncation;
int truncation_value;
- AttrType use;
- int use_value;
- const char *use_string = 0;
oid_value curAttributeSet = attributeSet;
const char *termp;
struct rpn_char_map_info rcmi;
*ol = ord_list_create(stream);
rpn_char_map_prepare (zh->reg, reg_type, &rcmi);
- attr_init(&use, zapt, 1);
- use_value = attr_find_ex(&use, &curAttributeSet, &use_string);
- yaz_log(log_level_rpn, "string_term, use value %d", use_value);
- attr_init(&truncation, zapt, 5);
+ attr_init_APT(&truncation, zapt, 5);
truncation_value = attr_find(&truncation, NULL);
yaz_log(log_level_rpn, "truncation value %d", truncation_value);
- if (use_value == -1) /* no attribute - assumy "any" */
- use_value = 1016;
for (base_no = 0; base_no < num_bases; base_no++)
{
int ord = -1;
int attr_ok = 0;
int regex_range = 0;
int init_pos = 0;
+#if 0
attent attp;
data1_local_attribute id_xpath_attr;
data1_local_attribute *local_attr;
+#endif
int max_pos, prefix_len = 0;
int relation_error;
+ char ord_buf[32];
+ int ord_len, i;
termp = *term_sub;
basenames[base_no]);
return ZEBRA_FAIL;
}
- if (xpath_use > 0 && use_value == -2)
- {
- /* xpath mode and we have a string attribute */
- attp.local_attributes = &id_xpath_attr;
- attp.attset_ordinal = VAL_IDXPATH;
- id_xpath_attr.next = 0;
-
- use_value = xpath_use; /* xpath_use as use-attribute now */
- id_xpath_attr.local = use_value;
- }
- else if (curAttributeSet == VAL_IDXPATH && use_value >= 0)
+
+ if (zebra_apt_get_ord(zh, zapt, reg_type, xpath_use,
+ curAttributeSet, &ord)
+ != ZEBRA_OK)
{
- /* X-Path attribute, use numeric value directly */
- attp.local_attributes = &id_xpath_attr;
- attp.attset_ordinal = VAL_IDXPATH;
- id_xpath_attr.next = 0;
- id_xpath_attr.local = use_value;
+ break;
}
- else if (use_string &&
- (ord = zebraExplain_lookup_attr_str(zh->reg->zei,
- reg_type,
- use_string)) >= 0)
- {
- /* we have a match for a raw string attribute */
- char ord_buf[32];
- int i, ord_len;
-
- if (prefix_len)
- term_dict[prefix_len++] = '|';
- else
- term_dict[prefix_len++] = '(';
-
- ord_len = key_SU_encode (ord, ord_buf);
- for (i = 0; i<ord_len; i++)
- {
- term_dict[prefix_len++] = 1;
- term_dict[prefix_len++] = ord_buf[i];
- }
- attp.local_attributes = 0; /* no more attributes */
- *ol = ord_list_append(stream, *ol, ord);
- }
- else
+ *ol = ord_list_append(stream, *ol, ord);
+
+ if (prefix_len)
+ term_dict[prefix_len++] = '|';
+ else
+ term_dict[prefix_len++] = '(';
+
+ ord_len = key_SU_encode (ord, ord_buf);
+ for (i = 0; i<ord_len; i++)
{
- /* lookup in the .att files . Allow string as well */
- if ((r = att_getentbyatt (zh, &attp, curAttributeSet, use_value,
- use_string)))
- {
- yaz_log(YLOG_DEBUG, "att_getentbyatt fail. set=%d use=%d r=%d",
- curAttributeSet, use_value, r);
- if (r == -1)
- {
- /* set was found, but value wasn't defined */
- if (use_string)
- zebra_setError(zh,
- YAZ_BIB1_UNSUPP_USE_ATTRIBUTE,
- use_string);
- else
- zebra_setError_zint(zh, YAZ_BIB1_UNSUPP_USE_ATTRIBUTE,
- use_value);
- }
- else
- {
- int oid[OID_SIZE];
- struct oident oident;
-
- oident.proto = PROTO_Z3950;
- oident.oclass = CLASS_ATTSET;
- oident.value = curAttributeSet;
- oid_ent_to_oid (&oident, oid);
-
- zebra_setError(zh,
- YAZ_BIB1_UNSUPP_ATTRIBUTE_SET,
- oident.desc);
-
- }
- continue;
- }
- }
- for (local_attr = attp.local_attributes; local_attr;
- local_attr = local_attr->next)
- {
- char ord_buf[32];
- int i, ord_len;
-
- ord = zebraExplain_lookup_attr_su(zh->reg->zei,
- reg_type,
- attp.attset_ordinal,
- local_attr->local);
- if (ord < 0)
- continue;
- *ol = ord_list_append(stream, *ol, ord);
- if (prefix_len)
- term_dict[prefix_len++] = '|';
- else
- term_dict[prefix_len++] = '(';
-
- ord_len = key_SU_encode (ord, ord_buf);
- for (i = 0; i<ord_len; i++)
- {
- term_dict[prefix_len++] = 1;
+ term_dict[prefix_len++] = 1;
term_dict[prefix_len++] = ord_buf[i];
- }
- if (ord_len > init_pos)
- init_pos = ord_len;
- }
+ }
+ if (ord_len > init_pos)
+ init_pos = ord_len;
+
bases_ok++;
if (prefix_len)
attr_ok = 1;
if (!zapt)
return ZEBRA_OK;
- attr_init(&termset, zapt, 8);
+ attr_init_APT(&termset, zapt, 8);
termset_value_numeric =
attr_find_ex(&termset, NULL, &termset_value_string);
if (termset_value_numeric != -1)
oid_value attributeSet,
NMEM stream,
int reg_type, int complete_flag,
- const char *rank_type, int xpath_use,
+ const char *rank_type,
+ const char *xpath_use,
int num_bases, char **basenames,
NMEM rset_nmem,
RSET **result_sets, int *num_result_sets,
oid_value attributeSet,
NMEM stream,
int reg_type, int complete_flag,
- const char *rank_type, int xpath_use,
+ const char *rank_type,
+ const char *xpath_use,
int num_bases, char **basenames,
NMEM rset_nmem,
RSET *rset,
NMEM stream,
int reg_type, int complete_flag,
const char *rank_type,
- int xpath_use,
+ const char *xpath_use,
int num_bases, char **basenames,
NMEM rset_nmem,
RSET *rset,
NMEM stream,
int reg_type, int complete_flag,
const char *rank_type,
- int xpath_use,
+ const char *xpath_use,
int num_bases, char **basenames,
NMEM rset_nmem,
RSET *rset,
char *term_tmp = term_dict + strlen(term_dict);
*error_code = 0;
- attr_init(&relation, zapt, 2);
+ attr_init_APT(&relation, zapt, 2);
relation_value = attr_find(&relation, NULL);
yaz_log(log_level_rpn, "numeric relation value=%d", relation_value);
struct grep_info *grep_info,
int reg_type, int complete_flag,
int num_bases, char **basenames,
- char *term_dst, int xpath_use, NMEM stream)
+ char *term_dst,
+ const char *xpath_use,
+ NMEM stream)
{
char term_dict[2*IT_MAX_WORD+2];
- int r, base_no;
- AttrType use;
- int use_value;
- const char *use_string = 0;
+ int base_no;
oid_value curAttributeSet = attributeSet;
const char *termp;
struct rpn_char_map_info rcmi;
int bases_ok = 0; /* no of databases with OK attribute */
rpn_char_map_prepare (zh->reg, reg_type, &rcmi);
- attr_init(&use, zapt, 1);
- use_value = attr_find_ex(&use, &curAttributeSet, &use_string);
-
- if (use_value == -1)
- use_value = 1016;
for (base_no = 0; base_no < num_bases; base_no++)
{
- attent attp;
- data1_local_attribute id_xpath_attr;
- data1_local_attribute *local_attr;
int max_pos, prefix_len = 0;
int relation_error = 0;
+ int ord, ord_len, i;
+ char ord_buf[32];
termp = *term_sub;
- if (use_value == -2) /* string attribute (assume IDXPATH/any) */
- {
- use_value = xpath_use;
- attp.local_attributes = &id_xpath_attr;
- attp.attset_ordinal = VAL_IDXPATH;
- id_xpath_attr.next = 0;
- id_xpath_attr.local = use_value;
- }
- else if (curAttributeSet == VAL_IDXPATH)
- {
- attp.local_attributes = &id_xpath_attr;
- attp.attset_ordinal = VAL_IDXPATH;
- id_xpath_attr.next = 0;
- id_xpath_attr.local = use_value;
- }
- else
- {
- if ((r = att_getentbyatt (zh, &attp, curAttributeSet, use_value,
- use_string)))
- {
- yaz_log(YLOG_DEBUG, "att_getentbyatt fail. set=%d use=%d r=%d",
- curAttributeSet, use_value, r);
- if (r == -1)
- {
- if (use_string)
- zebra_setError(zh,
- YAZ_BIB1_UNSUPP_USE_ATTRIBUTE,
- use_string);
- else
- zebra_setError_zint(zh, YAZ_BIB1_UNSUPP_USE_ATTRIBUTE,
- use_value);
- }
- else
- zebra_setError(zh, YAZ_BIB1_UNSUPP_ATTRIBUTE_SET, 0);
- continue;
- }
- }
+
if (zebraExplain_curDatabase (zh->reg->zei, basenames[base_no]))
{
zebra_setError(zh, YAZ_BIB1_DATABASE_UNAVAILABLE,
basenames[base_no]);
return ZEBRA_FAIL;
}
- for (local_attr = attp.local_attributes; local_attr;
- local_attr = local_attr->next)
- {
- int ord;
- char ord_buf[32];
- int i, ord_len;
-
- ord = zebraExplain_lookup_attr_su(zh->reg->zei,
- reg_type,
- attp.attset_ordinal,
- local_attr->local);
- if (ord < 0)
- continue;
- if (prefix_len)
- term_dict[prefix_len++] = '|';
- else
- term_dict[prefix_len++] = '(';
- ord_len = key_SU_encode (ord, ord_buf);
- for (i = 0; i<ord_len; i++)
- {
- term_dict[prefix_len++] = 1;
- term_dict[prefix_len++] = ord_buf[i];
- }
+ if (zebra_apt_get_ord(zh, zapt, reg_type, xpath_use,
+ curAttributeSet, &ord)
+ != ZEBRA_OK)
+ {
+ break;
}
- if (!prefix_len)
+
+ if (prefix_len)
+ term_dict[prefix_len++] = '|';
+ else
+ term_dict[prefix_len++] = '(';
+
+ ord_len = key_SU_encode (ord, ord_buf);
+ for (i = 0; i < ord_len; i++)
{
- zebra_setError_zint(zh, YAZ_BIB1_UNSUPP_USE_ATTRIBUTE, use_value);
- continue;
+ term_dict[prefix_len++] = 1;
+ term_dict[prefix_len++] = ord_buf[i];
}
bases_ok++;
term_dict[prefix_len++] = ')';
oid_value attributeSet,
NMEM stream,
int reg_type, int complete_flag,
- const char *rank_type, int xpath_use,
+ const char *rank_type,
+ const char *xpath_use,
int num_bases, char **basenames,
NMEM rset_nmem,
RSET *rset,
oident oe;
char termz[20];
- attr_init(&sort_relation_type, zapt, 7);
+ attr_init_APT(&sort_relation_type, zapt, 7);
sort_relation_value = attr_find(&sort_relation_type, &attributeSet);
if (!sort_sequence->specs)
AttrType use;
const char *use_string = 0;
- attr_init(&use, zapt, 1);
+ attr_init_APT(&use, zapt, 1);
attr_find_ex(&use, &curAttributeSet, &use_string);
if (!use_string || *use_string != '/')
static RSET xpath_trunc(ZebraHandle zh, NMEM stream,
- int reg_type, const char *term, int use,
+ int reg_type, const char *term,
+ const char *xpath_use,
oid_value curAttributeSet, NMEM rset_nmem,
struct rset_key_control *kc)
{
char term_dict[2048];
char ord_buf[32];
int prefix_len = 0;
- int ord = zebraExplain_lookup_attr_su(zh->reg->zei, reg_type,
- curAttributeSet, use);
+ int ord = zebraExplain_lookup_attr_str(zh->reg->zei, reg_type,
+ xpath_use);
int ord_len, i, r, max_pos;
int term_type = Z_Term_characterString;
const char *flags = "void";
}
wrbuf_puts(wbuf, "");
rset_attr = xpath_trunc(
- zh, stream, '0', wrbuf_buf(wbuf), 3,
+ zh, stream, '0', wrbuf_buf(wbuf), ZEBRA_XPATH_ATTR_NAME,
curAttributeSet, rset_nmem, kc);
wrbuf_free(wbuf, 1);
}
if (strlen(xpath_rev))
{
rset_start_tag = xpath_trunc(zh, stream, '0',
- xpath_rev, 1, curAttributeSet, rset_nmem, kc);
+ xpath_rev,
+ ZEBRA_XPATH_ELM_BEGIN,
+ curAttributeSet,
+ rset_nmem, kc);
rset_end_tag = xpath_trunc(zh, stream, '0',
- xpath_rev, 2, curAttributeSet, rset_nmem, kc);
+ xpath_rev,
+ ZEBRA_XPATH_ELM_END,
+ curAttributeSet,
+ rset_nmem, kc);
rset = rsbetween_create(rset_nmem, kc, kc->scope,
rset_start_tag, rset,
int sort_flag;
char termz[IT_MAX_WORD+1];
int xpath_len;
- int xpath_use = 0;
+ const char *xpath_use = 0;
struct xpath_location_step xpath[10];
if (!log_level_set)
xpath_len = parse_xpath(zh, zapt, attributeSet, xpath, 10, stream);
if (xpath_len >= 0)
{
- xpath_use = 1016; /* searching for element by default */
if (xpath[xpath_len-1].part[0] == '@')
- xpath_use = 1015; /* last step an attribute .. */
+ xpath_use = ZEBRA_XPATH_ATTR_CDATA; /* last step is attribute */
+ else
+ xpath_use = ZEBRA_XPATH_CDATA; /* searching for cdata */
}
/* search using one of the various search type strategies
int errCode = 0; /* err code (if any is not OK) */
char *errString = 0; /* addinfo */
- unsigned reg_id;
+ unsigned index_type;
char *search_type = NULL;
char rank_type[128];
int complete_flag;
AttrType termset;
int termset_value_numeric;
const char *termset_value_string;
- attr_init(&termset, zapt, 8);
+ attr_init_APT(&termset, zapt, 8);
termset_value_numeric =
attr_find_ex(&termset, NULL, &termset_value_string);
if (termset_value_numeric != -1)
yaz_log(YLOG_DEBUG, "position = %d, num = %d set=%d",
pos, num, attributeset);
- attr_init(&use, zapt, 1);
+ attr_init_APT(&use, zapt, 1);
use_value = attr_find_ex(&use, &attributeset, &use_string);
- if (zebra_maps_attr(zh->reg->zebra_maps, zapt, ®_id, &search_type,
+ if (zebra_maps_attr(zh->reg->zebra_maps, zapt, &index_type, &search_type,
rank_type, &complete_flag, &sort_flag))
{
*num_entries = 0;
use_value = 1016;
for (base_no = 0; base_no < num_bases && ord_no < 32; base_no++)
{
- data1_local_attribute *local_attr;
- attent attp;
int ord;
if (zebraExplain_curDatabase (zh->reg->zei, basenames[base_no]))
return ZEBRA_FAIL;
}
- if (use_string &&
- (ord = zebraExplain_lookup_attr_str(zh->reg->zei, reg_id,
- use_string)) >= 0)
- {
- /* we have a match for a raw string attribute */
- if (ord > 0)
- ords[ord_no++] = ord;
- attp.local_attributes = 0; /* no more attributes */
- }
- else
- {
- int r;
-
- if ((r = att_getentbyatt (zh, &attp, attributeset, use_value,
- use_string)))
- {
- yaz_log(YLOG_DEBUG, "att_getentbyatt fail. set=%d use=%d",
- attributeset, use_value);
- if (r == -1)
- {
- errCode = YAZ_BIB1_UNSUPP_USE_ATTRIBUTE;
- if (use_string)
- zebra_setError(zh, YAZ_BIB1_UNSUPP_USE_ATTRIBUTE,
- use_string);
- else
- zebra_setError_zint(zh, YAZ_BIB1_UNSUPP_USE_ATTRIBUTE,
- use_value);
- }
- else
- {
- zebra_setError(zh, YAZ_BIB1_UNSUPP_ATTRIBUTE_SET, 0);
- }
- continue;
- }
- }
- bases_ok++;
- for (local_attr = attp.local_attributes; local_attr && ord_no < 32;
- local_attr = local_attr->next)
- {
- ord = zebraExplain_lookup_attr_su(zh->reg->zei, reg_id,
- attp.attset_ordinal,
- local_attr->local);
- if (ord > 0)
- ords[ord_no++] = ord;
- }
+ if (zebra_apt_get_ord(zh, zapt, index_type, 0, attributeset, &ord)
+ != ZEBRA_OK)
+ {
+ break;
+ }
+ ords[ord_no++] = ord;
}
if (!bases_ok && errCode)
{
struct scan_info *scan_info = scan_info_array + i;
struct rpn_char_map_info rcmi;
- rpn_char_map_prepare (zh->reg, reg_id, &rcmi);
+ rpn_char_map_prepare (zh->reg, index_type, &rcmi);
scan_info->before = before;
scan_info->after = after;
termz[prefix_len] = 0;
strcpy(scan_info->prefix, termz);
- if (trans_scan_term(zh, zapt, termz+prefix_len, reg_id) == ZEBRA_FAIL)
+ if (trans_scan_term(zh, zapt, termz+prefix_len, index_type) ==
+ ZEBRA_FAIL)
return ZEBRA_FAIL;
dict_scan(zh->reg->dict, termz, &before_tmp, &after_tmp,
if (lo >= 0)
{
/* get result set for first term */
- zebra_term_untrans_iconv(zh, stream->mem, reg_id,
+ zebra_term_untrans_iconv(zh, stream->mem, index_type,
&glist[lo].term, mterm);
rset = rset_trunc(zh, &scan_info_array[j0].list[ptr[j0]].isam_p, 1,
glist[lo].term, strlen(glist[lo].term),
NULL, 0, zapt->term->which, rset_nmem,
- kc, kc->scope, 0, reg_id, 0 /* hits_limit */,
+ kc, kc->scope, 0, index_type, 0 /* hits_limit */,
0 /* term_ref_id_str */);
}
ptr[j0]++; /* move index for this set .. */
glist[lo].term,
strlen(glist[lo].term), NULL, 0,
zapt->term->which,rset_nmem,
- kc, kc->scope, 0, reg_id, 0 /* hits_limit */,
+ kc, kc->scope, 0, index_type, 0 /* hits_limit */,
0 /* term_ref_id_str */ );
rset = rsmulti_or_create(rset_nmem, kc,
kc->scope, 0 /* termid */,
if (j0 == -1)
break;
- zebra_term_untrans_iconv(zh, stream->mem, reg_id,
+ zebra_term_untrans_iconv(zh, stream->mem, index_type,
&glist[lo].term, mterm);
rset = rset_trunc
(zh, &scan_info_array[j0].list[before-1-ptr[j0]].isam_p, 1,
glist[lo].term, strlen(glist[lo].term),
NULL, 0, zapt->term->which, rset_nmem,
- kc, kc->scope, 0, reg_id, 0 /* hits_limit */,
+ kc, kc->scope, 0, index_type, 0 /* hits_limit */,
0 /* term_ref_id_str */);
ptr[j0]++;
glist[lo].term,
strlen(glist[lo].term), NULL, 0,
zapt->term->which, rset_nmem,
- kc, kc->scope, 0, reg_id, 0 /* hits_limit */,
+ kc, kc->scope, 0, index_type, 0 /* hits_limit */,
0 /* term_ref_id_str */);
rset = rsmulti_or_create(rset_nmem, kc,
kc->scope, 0 /* termid */, 2, rsets);
-/* $Id: zsets.c,v 1.102 2006-05-18 12:03:05 adam Exp $
+/* $Id: zsets.c,v 1.103 2006-05-19 13:49:35 adam Exp $
Copyright (C) 1995-2006
Index Data ApS
if (zh->m_staticrank)
sysno_mem_index = 1;
-
assert(nmem); /* compiler shut up about unused param */
sset->sort_info->num_entries = 0;
case Z_SortKey_sortField:
yaz_log(log_level_sort, "key %d is of type sortField",
i+1);
- zebra_setError(zh, YAZ_BIB1_CANNOT_SORT_ACCORDING_TO_SEQUENCE, 0);
- return ZEBRA_FAIL;
+ sort_criteria[i].numerical = 0;
+ sort_criteria[i].ord =
+ zebraExplain_lookup_attr_str(zh->reg->zei, 's',
+ sk->u.sortField);
+ if (sort_criteria[i].ord == -1)
+ {
+ zebra_setError(zh,
+ YAZ_BIB1_CANNOT_SORT_ACCORDING_TO_SEQUENCE, 0);
+ return ZEBRA_FAIL;
+ }
+ break;
case Z_SortKey_elementSpec:
yaz_log(log_level_sort, "key %d is of type elementSpec",
i+1);
return ZEBRA_FAIL;
case Z_SortKey_sortAttributes:
yaz_log(log_level_sort, "key %d is of type sortAttributes", i+1);
- if (1)
- {
- int ord;
- int use = zebra_maps_sort(zh->reg->zebra_maps,
- sk->u.sortAttributes,
- &sort_criteria[i].numerical);
- yaz_log(log_level_sort, "use value = %d", use);
- if (use == -1)
- {
- zebra_setError(
- zh, YAZ_BIB1_USE_ATTRIBUTE_REQUIRED_BUT_NOT_SUPPLIED, 0);
- return ZEBRA_FAIL;
- }
- ord = zebraExplain_lookup_attr_su_any_index(zh->reg->zei,
- VAL_IDXPATH, use);
- if (ord == -1)
- {
- zebra_setError(
- zh, YAZ_BIB1_CANNOT_SORT_ACCORDING_TO_SEQUENCE, 0);
- return ZEBRA_FAIL;
- }
- sort_criteria[i].ord = ord;
- }
+ if (zebra_sort_get_ord(zh, sk->u.sortAttributes,
+ &sort_criteria[i].ord,
+ &sort_criteria[i].numerical)
+ != ZEBRA_OK)
+ return ZEBRA_FAIL;
break;
}
}
-/* $Id: recgrs.c,v 1.109 2006-05-10 08:13:28 adam Exp $
- Copyright (C) 1995-2005
+/* $Id: recgrs.c,v 1.110 2006-05-19 13:49:35 adam Exp $
+ Copyright (C) 1995-2006
Index Data ApS
This file is part of the Zebra server.
char *structure, struct recExtractCtrl *p,
RecWord *wrd)
{
-#if NATTR
wrd->index_name = ZEBRA_XPATH_ELM_BEGIN;
-#else
- wrd->attrSet = VAL_IDXPATH;
- wrd->attrUse = 1;
-#endif
wrd->index_type = '0';
wrd->term_buf = tag_path;
wrd->term_len = strlen(tag_path);
(*p->tokenAdd)(wrd);
if (value) {
-#if NATTR
- wrd->index_name = ZEBRA_XPATH_ATTR;
-#else
- wrd->attrUse = 1015;
-#endif
+ wrd->index_name = ZEBRA_XPATH_ATTR_CDATA;
wrd->index_type = 'w';
wrd->term_buf = value;
wrd->term_len = strlen(value);
(*p->tokenAdd)(wrd);
}
-#if NATTR
wrd->index_name = ZEBRA_XPATH_ELM_END;
-#else
- wrd->attrUse = 2;
-#endif
wrd->index_type = '0';
wrd->term_buf = tag_path;
wrd->term_len = strlen(tag_path);
static void index_xpath(struct source_parser *sp, data1_node *n,
struct recExtractCtrl *p,
int level, RecWord *wrd,
-#if NATTR
char *xpath_index,
int xpath_is_start
-#else
- int use
-#endif
)
{
int i;
int termlist_only = 1;
data1_termlist *tl;
int xpdone = 0;
-#if NATTR
-#else
- int xpath_is_start = 0;
- if (use == 1)
- xpath_is_start = 1;
-#endif
-
-#if NATTR
yaz_log(YLOG_DEBUG, "index_xpath level=%d xpath_index=%s",
level, xpath_index);
-#else
- yaz_log(YLOG_DEBUG, "index_xpath level=%d use=%d", level, use);
-#endif
if ((!n->root->u.root.absyn) ||
(n->root->u.root.absyn->enable_xpath_indexing)) {
termlist_only = 0;
memcpy (&wrd_tl, wrd, sizeof(*wrd));
if (tl->source)
sp_parse(sp, n, &wrd_tl, tl->source);
-#if NATTR
if (!tl->index_name)
-#else
- if (!tl->att)
-#endif
{
/* this is the ! case, so structure is for the xpath index */
-#if NATTR
wrd_tl.index_name = xpath_index;
-#else
- wrd_tl.attrSet = VAL_IDXPATH;
- wrd_tl.attrUse = use;
-#endif
if (p->flagShowRecords)
{
int i;
xpdone = 1;
} else {
/* this is just the old fashioned attribute based index */
-#if NATTR
wrd_tl.index_name = tl->index_name;
-#else
- wrd_tl.attrSet = (int) (tl->att->parent->reference);
- wrd_tl.attrUse = tl->att->locals->local;
-#endif
if (p->flagShowRecords)
{
int i;
printf("%*sIdx: [%s]", (level + 1) * 4, "",
tl->structure);
-#if NATTR
printf("%s %s", tl->index_name, tl->source);
-#else
- printf("%s:%s [%d] %s",
- tl->att->parent->name,
- tl->att->name, tl->att->value,
- tl->source);
-#endif
printf (" XData:\"");
for (i = 0; i<wrd_tl.term_len && i < 40; i++)
fputc (wrd_tl.term_buf[i], stdout);
or no ! in the termlist, and default indexing is enabled... */
if (!p->flagShowRecords && !xpdone && !termlist_only)
{
-#if NATTR
wrd->index_name = xpath_index;
-#else
- wrd->attrSet = VAL_IDXPATH;
- wrd->attrUse = use;
-#endif
wrd->index_type = 'w';
(*p->tokenAdd)(wrd);
}
wrd->index_type = '0';
wrd->term_buf = tag_path_full;
wrd->term_len = strlen(tag_path_full);
-#if NATTR
wrd->index_name = xpath_index;
-#else
- wrd->attrSet = VAL_IDXPATH;
- wrd->attrUse = use;
-#endif
if (p->flagShowRecords)
{
printf("%*s tag=", (level + 1) * 4, "");
{
for (; tl; tl = tl->next)
{
-#if NATTR
if (!tl->index_name)
-#else
- if (!tl->att)
-#endif
do_xpindex = 1;
}
}
{
for (; tl; tl = tl->next)
{
-#if NATTR
if (!tl->index_name)
do_xpindex = 1;
-#else
- if (!tl->att)
- do_xpindex = 1;
-#endif
}
}
/* attribute (no value) */
wrd->index_type = '0';
-#if NATTR
- wrd->index_name = ZEBRA_XPATH_ATTR;
-#else
- wrd->attrUse = 3;
-#endif
+ wrd->index_name = ZEBRA_XPATH_ATTR_NAME;
wrd->term_buf = xp->name;
wrd->term_len = strlen(xp->name);
strcat (comb, "=");
strcat (comb, xp->value);
-#if NATTR
- wrd->index_name = ZEBRA_XPATH_ATTR;
-#else
- wrd->attrUse = 3;
-#endif
+ wrd->index_name = ZEBRA_XPATH_ATTR_NAME;
wrd->index_type = '0';
wrd->term_buf = comb;
wrd->term_len = strlen(comb);
/* If there is a termlist given (=xelm directive) */
for (; tl; tl = tl->next)
{
-#if NATTR
if (!tl->index_name)
-#else
- if (!tl->att)
-#endif
{
/* add xpath index for the attribute */
index_xpath_attr (attr_tag_path_full, xp->name,
/* index attribute value (only path/@attr) */
if (xp->value)
{
-#if NATTR
wrd->index_name = tl->index_name;
-#else
- wrd->attrSet = (int)
- (tl->att->parent->reference);
- wrd->attrUse = tl->att->locals->local;
-#endif
wrd->index_type = *tl->structure;
wrd->term_buf = xp->value;
wrd->term_len = strlen(xp->value);
int i;
printf("%*sIdx: [%s]", (level + 1) * 4, "",
tlist->structure);
-#if NATTR
printf("%s %s", tlist->index_name, tlist->source);
-#else
- printf("%s:%s [%d] %s",
- tlist->att->parent->name,
- tlist->att->name, tlist->att->value,
- tlist->source);
-#endif
printf (" XData:\"");
for (i = 0; i<wrd->term_len && i < 40; i++)
fputc (wrd->term_buf[i], stdout);
else
{
wrd->index_type = *tlist->structure;
-#if NATTR
wrd->index_name = tlist->index_name;
-#else
- wrd->attrSet = (int) (tlist->att->parent->reference);
- wrd->attrUse = tlist->att->locals->local;
-#endif
(*p->tokenAdd)(wrd);
}
}
{
index_termlist(sp, n, n, p, level, wrd);
/* index start tag */
-#if NATTR
if (n->root->u.root.absyn)
index_xpath(sp, n, p, level, wrd, ZEBRA_XPATH_ELM_BEGIN,
1 /* is start */);
-#else
- if (n->root->u.root.absyn)
- index_xpath(sp, n, p, level, wrd, 1);
-#endif
}
if (n->child)
if (par)
index_termlist(sp, par, n, p, level, wrd);
-#if NATTR
index_xpath(sp, n, p, level, wrd, ZEBRA_XPATH_CDATA,
0 /* is start */);
-#else
- index_xpath(sp, n, p, level, wrd, 1016);
-#endif
}
if (n->which == DATA1N_tag)
{
/* index end tag */
-#if NATTR
index_xpath(sp, n, p, level, wrd, ZEBRA_XPATH_ELM_END,
0 /* is start */);
-#else
- index_xpath(sp, n, p, level, wrd, 2);
-#endif
}
if (p->flagShowRecords && n->which == DATA1N_root)
# This is the abstract syntax (and most of the top-level profile info)
# for GILS version 2.
#
-# $Id: gils.abs,v 1.2 2002-12-02 16:55:14 adam Exp $
+# $Id: gils.abs,v 1.3 2006-05-19 13:49:35 adam Exp $
name gils
reference GILS-schema
systag sysno none
-#all Any
+all Any
elm (1,1) schemaIdentifier -
elm (1,10) rank -
-# $Id: Makefile.am,v 1.35 2006-04-27 20:40:41 marc Exp $
+# $Id: Makefile.am,v 1.36 2006-05-19 13:49:35 adam Exp $
noinst_PROGRAMS = testclient
testclient_SOURCES = testclient.c
-simpletests = t0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15
+simpletests = t0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t11 t12 t13 t14 t15
safaritests = safari1
check_PROGRAMS = $(simpletests) $(safaritests)
TESTS = $(check_PROGRAMS)
t7_SOURCES = t7.c
t8_SOURCES = t8.c
t9_SOURCES = t9.c rankingrecords.h
-t10_SOURCES = t10.c rankingrecords.h
t11_SOURCES = t11.c
t12_SOURCES = t12.c
t13_SOURCES = t13.c
+++ /dev/null
-/* $Id: t10.c,v 1.11 2006-05-10 08:13:35 adam Exp $
- Copyright (C) 1995-2005
- Index Data ApS
-
-This file is part of the Zebra server.
-
-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
-Software Foundation; either version 2, or (at your option) any later
-version.
-
-Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-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.
-*/
-
-/** t10.c - test zv-rank */
-
-#include "testlib.h"
-#include "rankingrecords.h"
-
-struct tst {
- char *schema;
- char *hit1;
- int score1;
- char *hit2;
- int score2;
- char *hit3;
- int score3;
-};
-
-struct tst tests[] = {
- {"ntc-atn", "first title", 0, "first title", 1000, "first title",1000 },
- {"ntc-ntn", "first title", 0, "first title", 1000, "first title",1000 },
- {"ntc-btn", "first title", 0, "first title", 1000, "first title",1000 },
- {"ntc-apn", "first title", 0, "first title", 1000, "first title",1000 },
- {"ntc-npn", "first title", 0, "first title", 1000, "first title",1000 },
- {"ntc-bpn", "first title", 0, "first title", 1000, "first title",1000 },
- {"atc-atn", "first title", 0, "first title", 1000, "first title", 1000 },
- {"atc-ntn", "first title", 0, "first title", 1000, "first title", 1000 },
- {"atc-btn", "first title", 0, "first title", 1000, "first title", 1000 },
- {"atc-apn", "first title", 0, "first title", 1000, "first title", 1000 },
- {"atc-npn", "first title", 0, "first title", 1000, "first title", 1000 },
- {"atc-bpn", "first title", 0, "first title", 1000, "first title", 1000 },
-
- {"npc-atn", "first title", 0, "first title", 1000, "first title", 1000 },
- {"npc-ntn", "first title", 0, "first title", 1000, "first title", 1000 },
- {"npc-btn", "first title", 0, "first title", 1000, "first title", 1000 },
- {"npc-apn", "first title", 0, "first title", 1000, "first title", 1000 },
- {"npc-npn", "first title", 0, "first title", 1000, "first title", 1000 },
- {"npc-bpn", "first title", 0, "first title", 1000, "first title", 1000 },
-
- {"apc-atn", "first title", 0, "first title", 1000, "first title", 1000 },
- {"apc-ntn", "first title", 0, "first title", 1000, "first title", 1000 },
- {"apc-btn", "first title", 0, "first title", 1000, "first title", 1000 },
- {"apc-apn", "first title", 0, "first title", 1000, "first title", 1000 },
- {"apc-npn", "first title", 0, "first title", 1000, "first title", 1000 },
- {"apc-bpn", "first title", 0, "first title", 1000, "first title", 1000 },
- {0,0,0,0,0,0,0},
-};
-
-static void tst(int argc, char **argv)
-{
- int i;
- ZebraService zs = tl_start_up("zebrazv.cfg", argc, argv);
- ZebraHandle zh = zebra_open(zs, 0);
-
- YAZ_CHECK(tl_init_data(zh, recs));
- zebra_close(zh);
- for (i = 0; tests[i].schema; i++)
- {
- zh = zebra_open(zs, 0);
- YAZ_CHECK(zh);
- YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK);
-
- zebra_set_resource(zh, "zvrank.weighting-scheme", tests[i].schema);
- yaz_log(YLOG_LOG,"============%d: %s ===========", i, tests[i].schema);
-
- YAZ_CHECK(tl_ranking_query(zh, "@attr 1=1016 @attr 2=102 the",
- 3, tests[i].hit1, tests[i].score1));
- YAZ_CHECK(tl_ranking_query(zh, "@attr 1=1016 @attr 2=102 @or foo bar",
- 3, tests[i].hit2, tests[i].score2));
- YAZ_CHECK(tl_ranking_query(zh,
- "@attr 1=1016 @attr 2=102 @or @or the foo bar",
- 3, tests[i].hit3, tests[i].score3));
- zebra_close(zh);
- }
- YAZ_CHECK(tl_close_down(0, zs));
-}
-
-TL_MAIN
-/*
- * Local variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- * vim: shiftwidth=4 tabstop=8 expandtab
- */
-
-/* $Id: t5.c,v 1.16 2006-05-10 08:13:35 adam Exp $
+/* $Id: t5.c,v 1.17 2006-05-19 13:49:35 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
YAZ_CHECK(tl_query(zh, "@attr 1=4 @and x title", 2));
/* exl=0 distance=2 order=1 relation=2 (<=), known, unit=word */
- YAZ_CHECK(tl_query(zh, "@prox 0 2 1 2 k 2 my x", 2));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @prox 0 2 1 2 k 2 my x", 2));
/* exl=0 distance=2 order=1 relation=2 (<=), known, unit=word */
- YAZ_CHECK(tl_query(zh, "@prox 0 2 1 2 k 2 x my", 0));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @prox 0 2 1 2 k 2 x my", 0));
/* exl=0 distance=2 order=0 relation=2 (<=), known, unit=word */
- YAZ_CHECK(tl_query(zh, "@prox 0 2 0 2 k 2 x my", 2));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @prox 0 2 0 2 k 2 x my", 2));
/* exl=0 distance=2 order=0 relation=3 (=), known, unit=word */
- YAZ_CHECK(tl_query(zh, "@prox 0 2 1 3 k 2 my x", 1));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @prox 0 2 1 3 k 2 my x", 1));
/* exl=1 distance=2 order=0 relation=3 (=), known, unit=word */
- YAZ_CHECK(tl_query(zh, "@prox 1 2 1 3 k 2 my x", 1));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @prox 1 2 1 3 k 2 my x", 1));
/* provoke unsupported use attribute */
YAZ_CHECK(tl_query_x(zh, "@attr 1=999 @attr 4=1 x", 0, 114));
0, 121));
/* provoke unsupported relation */
- YAZ_CHECK(tl_query_x(zh, "@attr 1=1016 @attr 2=6 x", 0, 117));
+ YAZ_CHECK(tl_query_x(zh, "@attr 1=4 @attr 2=6 x", 0, 117));
YAZ_CHECK(tl_query_x(zh, "@attr 1=1016 @attr 2=6 @attr 4=109 x", 0, 114));
YAZ_CHECK(tl_close_down(zh, zs));
-/* $Id: t8.c,v 1.10 2006-05-10 08:13:35 adam Exp $
+/* $Id: t8.c,v 1.11 2006-05-19 13:49:35 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
/* couple of simple queries just to see that we have indexed the stuff */
YAZ_CHECK(tl_query(zh, "@attr 1=4 title", 2));
- YAZ_CHECK(tl_query(zh, "title", 2));
/* 1=2038: West-Bounding-Coordinate 2039: East: 2040: North: 2041 South*/
/* 4=109: numeric string */
-/* $Id: t9.c,v 1.9 2006-05-10 08:13:35 adam Exp $
- Copyright (C) 1995-2005
+/* $Id: t9.c,v 1.10 2006-05-19 13:49:35 adam Exp $
+ Copyright (C) 1995-2006
Index Data ApS
This file is part of the Zebra server.
YAZ_CHECK(tl_init_data(zh, recs));
- YAZ_CHECK(tl_ranking_query(zh, "@attr 1=1016 @attr 2=102 the",
- 3, "first title", 997 ));
+ YAZ_CHECK(tl_ranking_query(zh, "@attr 1=4 @attr 2=102 the",
+ 3, "first title", 1000 ));
- YAZ_CHECK(tl_ranking_query(zh, "@attr 1=1016 @attr 2=102 foo",
+ YAZ_CHECK(tl_ranking_query(zh, "@attr 1=62 @attr 2=102 foo",
3, "second title", 850 ));
/* get the record with the most significant hit, that is the 'bar' */
/* as that is the rarest of my search words */
YAZ_CHECK(tl_ranking_query(zh, "@attr 1=1016 @attr 2=102 @or @or the foo bar",
- 3, "third title", 940 ));
+ 3, "third title", 813 ));
YAZ_CHECK(tl_close_down(zh, zs));
}
-/* $Id: charmap1.c,v 1.10 2006-05-10 08:13:36 adam Exp $
+/* $Id: charmap1.c,v 1.11 2006-05-19 13:49:35 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK);
zebra_commit(zh);
- YAZ_CHECK(tl_query(zh, "@term string æ", 1));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @term string æ", 1));
/* search for UNICODE 1E25 - letter h with dot below */
- YAZ_CHECK(tl_query(zh, "@term string ḥ", 1));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @term string ḥ", 1));
/* search for UNICODE A ring */
- YAZ_CHECK(tl_query(zh, "@term string lås", 1));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @term string lås", 1));
/* search for aa */
- YAZ_CHECK(tl_query(zh, "@term string laas", 1));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @term string laas", 1));
/* search for aa regular-1 */
- YAZ_CHECK(tl_query(zh, "@attr 5=102 @term string lås", 1));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=102 @term string lås", 1));
/* search for aa regular-2 */
- YAZ_CHECK(tl_query(zh, "@attr 5=103 @term string lås", 1));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=103 @term string lås", 1));
/* search for aa trunc=104 */
- YAZ_CHECK(tl_query(zh, "@attr 5=104 @term string laas", 1));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=104 @term string laas", 1));
/* search for aa trunc=105 */
- YAZ_CHECK(tl_query(zh, "@attr 5=104 @term string laas", 1));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=104 @term string laas", 1));
/* search for aaa */
- YAZ_CHECK(tl_query(zh, "@term string laaas", 0));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @term string laaas", 0));
/* search ABC in title:0 . */
- YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=4 ABC", 1));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=3 @attr 1=4 ABC", 1));
/* search DEF in title:0 . */
- YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=4 DEF", 0));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=3 @attr 1=4 DEF", 0));
/* search [ in title:0 . */
- YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=4 [", 1));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=3 @attr 1=4 [", 1));
/* search \ in title:0 . */
- YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=4 \\\\\\\\", 1));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=3 @attr 1=4 \\\\\\\\", 1));
/* search { in title:0 . */
- YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=4 \\{", 1));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=3 @attr 1=4 \\{", 1));
YAZ_CHECK(tl_close_down(zh, zs));
}
-/* $Id: grs.marc.c,v 1.4 2006-05-10 08:13:36 adam Exp $
+/* $Id: grs.marc.c,v 1.5 2006-05-19 13:49:35 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK);
zebra_commit(zh);
- YAZ_CHECK(tl_query(zh, "computer", 1));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 computer", 1));
- YAZ_CHECK(tl_query(zh, "computee", 0));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 computee", 0));
YAZ_CHECK(tl_close_down(zh, zs));
}
#!/bin/sh
-# $Id: test1.sh,v 1.14 2006-04-27 10:52:26 marc Exp $
+# $Id: test1.sh,v 1.15 2006-05-19 13:49:36 adam Exp $
srcdir=${srcdir:-"."}
echo "search 2..." >>$LOG
../api/testclient unix:socket "@or utah the" > log || exit 1
-grep "^Result count: 40$" log >/dev/null || exit 1
+grep "^Result count: 41$" log >/dev/null || exit 1
echo "search 3..." >>$LOG
../api/testclient unix:socket "@attr 1=4 the" > log || exit 1
#!/bin/sh
-# $Id: test3.sh,v 1.8 2006-04-27 10:52:26 marc Exp $
+# $Id: test3.sh,v 1.9 2006-05-19 13:49:36 adam Exp $
# Testing searches with lots of @and operators
# in order to test the fast-forward operation of rsets
../api/testclient -c 17 unix:socket utah > log || exit 1
echo "search A2..." >>$LOG
-../api/testclient -c 30 unix:socket the > log || exit 1
+../api/testclient -c 31 unix:socket the > log || exit 1
echo "search A3..." >>$LOG
../api/testclient -c 4 unix:socket deposits > log || exit 1
echo "search D1..." >>$LOG
-../api/testclient -c 29 unix:socket "@and the of " > log || exit 1
+../api/testclient -c 30 unix:socket "@and the of " > log || exit 1
echo "search D2..." >>$LOG
-../api/testclient -c 29 unix:socket "@and of the" > log || exit 1
+../api/testclient -c 30 unix:socket "@and of the" > log || exit 1
echo "search D3..." >>$LOG
-../api/testclient -c 29 unix:socket "@and @and the of of" > log || exit 1
+../api/testclient -c 30 unix:socket "@and @and the of of" > log || exit 1
echo "search D4..." >>$LOG
-../api/testclient -c 29 unix:socket "@and @and of the the" > log || exit 1
+../api/testclient -c 30 unix:socket "@and @and of the the" > log || exit 1
echo "search D5..." >>$LOG
-../api/testclient -c 29 unix:socket "@and @and @and the of of the" > log || exit 1
+../api/testclient -c 30 unix:socket "@and @and @and the of of the" > log || exit 1
echo "search D6..." >>$LOG
../api/testclient -c 15 unix:socket '@and @and in the data' > log || exit 1
# This one failed at early fast-forwards
echo "search E1..." >>$LOG
-../api/testclient -c 40 unix:socket "@or the utah" > log || exit 1
+../api/testclient -c 41 unix:socket "@or the utah" > log || exit 1
echo "search E2..." >>$LOG
-../api/testclient -c 40 unix:socket "@or utah the" > log || exit 1
+../api/testclient -c 41 unix:socket "@or utah the" > log || exit 1
echo "search E3..." >>$LOG
../api/testclient -c 42 unix:socket "@or deposits @or the utah" > log || exit 1
echo "search E4..." >>$LOG
-../api/testclient -c 2 unix:socket "@and deposits @or the utah" > log || exit 1
+../api/testclient -c 3 unix:socket "@and deposits @or the utah" > log || exit 1
echo "search E5..." >>$LOG
-../api/testclient -c 2 unix:socket "@and @or the utah deposits" > log || exit 1
+../api/testclient -c 3 unix:socket "@and @or the utah deposits" > log || exit 1
echo "search F1..." >>$LOG
-../api/testclient -c 23 unix:socket "@not the utah " > log || exit 1
+../api/testclient -c 24 unix:socket "@not the utah " > log || exit 1
echo "search F2..." >>$LOG
../api/testclient -c 10 unix:socket "@not utah the " > log || exit 1
-/* $Id: sort1.c,v 1.8 2006-05-10 08:13:39 adam Exp $
+/* $Id: sort1.c,v 1.9 2006-05-19 13:49:36 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
ids[1] = 2;
ids[2] = 4;
ids[3] = 5;
- YAZ_CHECK(tl_sort(zh, "@or computer @attr 7=1 @attr 1=30 0", 4, ids));
+ YAZ_CHECK(tl_sort(zh, "@or @attr 1=4 computer @attr 7=1 @attr 1=30 0", 4, ids));
ids[0] = 5;
ids[1] = 4;
ids[2] = 2;
ids[3] = 3;
- YAZ_CHECK(tl_sort(zh, "@or computer @attr 7=1 @attr 1=1021 0", 4, ids));
+ YAZ_CHECK(tl_sort(zh, "@or @attr 1=4 computer @attr 7=1 @attr 1=1021 0", 4, ids));
ids[0] = 2;
ids[1] = 5;
ids[2] = 4;
ids[3] = 3;
- YAZ_CHECK(tl_sort(zh, "@or computer @attr 7=1 @attr 1=1021 @attr 4=109 0", 4, ids));
+ YAZ_CHECK(tl_sort(zh, "@or @attr 1=4 computer @attr 7=1 @attr 1=1021 @attr 4=109 0", 4, ids));
YAZ_CHECK(tl_close_down(zh, zs));
}
-/* $Id: t1.c,v 1.6 2006-05-10 08:13:39 adam Exp $
+/* $Id: t1.c,v 1.7 2006-05-19 13:49:36 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
ids[1] = 5;
ids[2] = 3;
ids[3] = 4;
- YAZ_CHECK(tl_sort(zh, "@or computer @attr 7=1 @attr 1=4 0", 4, ids));
+ YAZ_CHECK(tl_sort(zh, "@or @attr 1=4 computer @attr 7=1 @attr 1=4 0", 4, ids));
YAZ_CHECK(tl_close_down(zh, zs));
}
-# $Id: zebra.cfg,v 1.6 2004-12-15 13:07:07 adam Exp $
+# $Id: zebra.cfg,v 1.7 2006-05-19 13:49:38 adam Exp $
profilePath: ${srcdir:-.}:${srcdir:-.}/../../tab
recordType: grs.sgml
attset: bib1.att
+attset: explain.att
isam:b
-## $Id: Makefile.am,v 1.17 2006-04-27 20:40:45 marc Exp $
+## $Id: Makefile.am,v 1.18 2006-05-19 13:49:38 adam Exp $
lib_LTLIBRARIES = libidzebra-util.la
LDADD = libidzebra-util.la $(YAZLALIB)
libidzebra_util_la_SOURCES = zint.c res.c charmap.c zebramap.c passwddb.c \
- zebra-lock.c dirent.c xpath.c atoi_zn.c snippet.c flock.c
+ zebra-lock.c dirent.c xpath.c atoi_zn.c snippet.c flock.c attrfind.c
passtest_SOURCES = passtest.c
--- /dev/null
+/* $Id: attrfind.c,v 1.1 2006-05-19 13:49:38 adam Exp $
+ Copyright (C) 2005-2006
+ Index Data ApS
+
+ This file is part of the Zebra server.
+
+ 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
+ Software Foundation; either version 2, or (at your option) any later
+ version.
+
+ Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ 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.
+*/
+
+#include <assert.h>
+
+#include <attrfind.h>
+
+void attr_init_APT(AttrType *src, Z_AttributesPlusTerm *zapt, int type)
+{
+ src->attributeList = zapt->attributes->attributes;
+ src->num_attributes = zapt->attributes->num_attributes;
+ src->type = type;
+ src->major = 0;
+ src->minor = 0;
+}
+
+void attr_init_AttrList(AttrType *src, Z_AttributeList *list, int type)
+{
+ src->attributeList = list->attributes;
+ src->num_attributes = list->num_attributes;
+ src->type = type;
+ src->major = 0;
+ src->minor = 0;
+}
+
+int attr_find_ex(AttrType *src, oid_value *attributeSetP,
+ const char **string_value)
+{
+ int num_attributes;
+
+ num_attributes = src->num_attributes;
+ while (src->major < num_attributes)
+ {
+ Z_AttributeElement *element;
+
+ element = src->attributeList[src->major];
+ if (src->type == *element->attributeType)
+ {
+ switch (element->which)
+ {
+ case Z_AttributeValue_numeric:
+ ++(src->major);
+ if (element->attributeSet && attributeSetP)
+ {
+ oident *attrset;
+
+ attrset = oid_getentbyoid(element->attributeSet);
+ *attributeSetP = attrset->value;
+ }
+ return *element->value.numeric;
+ break;
+ case Z_AttributeValue_complex:
+ if (src->minor >= element->value.complex->num_list)
+ break;
+ if (element->attributeSet && attributeSetP)
+ {
+ oident *attrset;
+
+ attrset = oid_getentbyoid(element->attributeSet);
+ *attributeSetP = attrset->value;
+ }
+ if (element->value.complex->list[src->minor]->which ==
+ Z_StringOrNumeric_numeric)
+ {
+ ++(src->minor);
+ return
+ *element->value.complex->list[src->minor-1]->u.numeric;
+ }
+ else if (element->value.complex->list[src->minor]->which ==
+ Z_StringOrNumeric_string)
+ {
+ if (!string_value)
+ break;
+ ++(src->minor);
+ *string_value =
+ element->value.complex->list[src->minor-1]->u.string;
+ return -2;
+ }
+ else
+ break;
+ default:
+ assert(0);
+ }
+ }
+ ++(src->major);
+ }
+ return -1;
+}
+
+int attr_find(AttrType *src, oid_value *attributeSetP)
+{
+ return attr_find_ex(src, attributeSetP, 0);
+}
+
+
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
-/* $Id: zebramap.c,v 1.48 2006-05-17 17:46:45 adam Exp $
- Copyright (C) 1995-2005
+/* $Id: zebramap.c,v 1.49 2006-05-19 13:49:38 adam Exp $
+ Copyright (C) 1995-2006
Index Data ApS
This file is part of the Zebra server.
#include <ctype.h>
#include <charmap.h>
+#include <attrfind.h>
#include <yaz/yaz-util.h>
#include <idzebra/zebramap.h>
}
-/* ------------------------------------ */
-
-typedef struct {
- int type;
- int major;
- int minor;
- Z_AttributeElement **attributeList;
- int num_attributes;
-} AttrType;
-
-static int attr_find(AttrType *src, oid_value *attributeSetP)
-{
- while (src->major < src->num_attributes)
- {
- Z_AttributeElement *element;
-
- element = src->attributeList[src->major];
- if (src->type == *element->attributeType)
- {
- switch (element->which)
- {
- case Z_AttributeValue_numeric:
- ++(src->major);
- if (element->attributeSet && attributeSetP)
- {
- oident *attrset;
-
- attrset = oid_getentbyoid(element->attributeSet);
- *attributeSetP = attrset->value;
- }
- return *element->value.numeric;
- break;
- case Z_AttributeValue_complex:
- if (src->minor >= element->value.complex->num_list ||
- element->value.complex->list[src->minor]->which !=
- Z_StringOrNumeric_numeric)
- break;
- ++(src->minor);
- if (element->attributeSet && attributeSetP)
- {
- oident *attrset;
-
- attrset = oid_getentbyoid(element->attributeSet);
- *attributeSetP = attrset->value;
- }
- return *element->value.complex->list[src->minor-1]->u.numeric;
- default:
- assert(0);
- }
- }
- ++(src->major);
- }
- return -1;
-}
-
-static void attr_init_APT(AttrType *src, Z_AttributesPlusTerm *zapt, int type)
-{
- src->attributeList = zapt->attributes->attributes;
- src->num_attributes = zapt->attributes->num_attributes;
- src->type = type;
- src->major = 0;
- src->minor = 0;
-}
-
-static void attr_init_AttrList(AttrType *src, Z_AttributeList *list, int type)
-{
- src->attributeList = list->attributes;
- src->num_attributes = list->num_attributes;
- src->type = type;
- src->major = 0;
- src->minor = 0;
-}
/* ------------------------------------ */
# Zebra makefile for MS NMAKE
-# $Id: makefile,v 1.43 2006-03-29 08:38:45 adam Exp $
+# $Id: makefile,v 1.44 2006-05-19 13:49:38 adam Exp $
###########################################################
############### Parameters
$(MOD_XSLT_OBJS) \
$(OBJDIR)\atoi_zn.obj \
$(OBJDIR)\attribute.obj \
+ $(OBJDIR)\attrfind.obj \
$(OBJDIR)\bfile.obj \
$(OBJDIR)\bset.obj \
$(OBJDIR)\cfile.obj \