-/* $Id: recctrl.h,v 1.36 2007-10-29 13:43:57 adam Exp $
+/* $Id: recctrl.h,v 1.37 2007-10-29 16:57:51 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
/** Indexing token */
typedef struct {
/** index type ('w', 'p', .. */
- unsigned index_type;
+ const char *index_type;
/** index name, e.g. "title" */
const char *index_name;
/** token char data */
-/* $Id: zebramap.h,v 1.22 2007-01-22 18:15:03 adam Exp $
+/* $Id: zebramap.h,v 1.23 2007-10-29 16:57:51 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
YAZ_EXPORT
int zebra_maps_attr (ZebraMaps zms, Z_AttributesPlusTerm *zapt,
- unsigned *reg_id, char **search_type, char *rank_type,
+ const char **reg_id, char **search_type, char *rank_type,
int *complete_flag, int *sort_flag);
YAZ_EXPORT
-/* $Id: alvis.c,v 1.19 2007-08-31 07:02:24 adam Exp $
+/* $Id: alvis.c,v 1.20 2007-10-29 16:57:52 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
static const char *zebra_xslt_ns = ZEBRA_SCHEMA_XSLT_NS;
-static void set_param_xml(const char **params, const char *name,
- const char *value, ODR odr)
-{
- while (*params)
- params++;
- params[0] = name;
- params[1] = value;
- params[2] = 0;
-}
-
static void set_param_str(const char **params, const char *name,
const char *value, ODR odr)
{
}
if (name_str)
{
- int prev_type = recWord->index_type; /* save default type */
+ const char *prev_type = recWord->index_type; /* save default type */
if (type_str && *type_str)
- recWord->index_type = *type_str; /* type was given */
+ recWord->index_type = (const char *) type_str; /* type was given */
recWord->index_name = name_str;
index_cdata(tinfo, ctrl, ptr->children, recWord);
-/* $Id: attribute.c,v 1.32 2007-05-25 12:17:11 adam Exp $
+/* $Id: attribute.c,v 1.33 2007-10-29 16:57:52 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
ZEBRA_RES zebra_attr_list_get_ord(ZebraHandle zh,
Z_AttributeList *attr_list,
zinfo_index_category_t cat,
- int index_type,
+ const char *index_type,
const Odr_oid *curAttributeSet,
int *ord)
{
ZEBRA_RES zebra_apt_get_ord(ZebraHandle zh,
Z_AttributesPlusTerm *zapt,
- int index_type,
+ const char *index_type,
const char *xpath_use,
const Odr_oid *curAttributeSet,
int *ord)
xpath_use);
if (*ord == -1)
{
- yaz_log(YLOG_LOG, "zebra_apt_get_ord FAILED xpath=%s index_type=%c",
+ yaz_log(YLOG_LOG, "zebra_apt_get_ord FAILED xpath=%s index_type=%s",
xpath_use, index_type);
zebra_setError(zh, YAZ_BIB1_UNSUPP_USE_ATTRIBUTE, 0);
res = ZEBRA_FAIL;
}
else
{
- yaz_log(YLOG_LOG, "zebra_apt_get_ord OK xpath=%s index_type=%c",
+ yaz_log(YLOG_LOG, "zebra_apt_get_ord OK xpath=%s index_type=%s",
xpath_use, index_type);
}
if (zebra_attr_list_get_ord(
zh, sortAttributes->list,
zinfo_index_category_sort,
- -1 /* any index */, yaz_oid_attset_bib_1, ord) == ZEBRA_OK)
+ 0 /* any index */, yaz_oid_attset_bib_1, ord) == ZEBRA_OK)
return ZEBRA_OK;
return ZEBRA_FAIL;
}
-/* $Id: extract.c,v 1.264 2007-10-29 13:43:57 adam Exp $
+/* $Id: extract.c,v 1.265 2007-10-29 16:57:52 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
{
w->seqno = 1;
w->index_name = "any";
- w->index_type = 'w';
+ w->index_type = "w";
w->extractCtrl = p;
w->record_id = 0;
w->section_id = 0;
const char *last = 0;
if (remain > 0)
- map = zebra_maps_input(zh->reg->zebra_maps, p->index_type, &b, remain, 1);
+ map = zebra_maps_input(zh->reg->zebra_maps, *p->index_type, &b, remain, 1);
while (remain > 0 && i < IT_MAX_WORD)
{
{
int first = i ? 0 : 1; /* first position */
- map = zebra_maps_input(zh->reg->zebra_maps, p->index_type,
+ map = zebra_maps_input(zh->reg->zebra_maps, *p->index_type,
&b, remain, first);
}
else
remain = p->term_len - (b - p->term_buf);
if (remain > 0)
{
- map = zebra_maps_input(zh->reg->zebra_maps, p->index_type, &b,
+ map = zebra_maps_input(zh->reg->zebra_maps, *p->index_type, &b,
remain, 0);
}
else
const char *last = b;
if (remain > 0)
- map = zebra_maps_input(zh->reg->zebra_maps, p->index_type, &b, remain, 0);
+ map = zebra_maps_input(zh->reg->zebra_maps, *p->index_type, &b, remain, 0);
while (map)
{
remain = p->term_len - (b - p->term_buf);
last = b;
if (remain > 0)
- map = zebra_maps_input(zh->reg->zebra_maps, p->index_type, &b,
+ map = zebra_maps_input(zh->reg->zebra_maps, *p->index_type, &b,
remain, 0);
else
map = 0;
remain = p->term_len - (b - p->term_buf);
last = b;
if (remain > 0)
- map = zebra_maps_input(zh->reg->zebra_maps, p->index_type, &b, remain, 0);
+ map = zebra_maps_input(zh->reg->zebra_maps, *p->index_type, &b, remain, 0);
else
map = 0;
}
if (first)
{
first = 0;
- if (zebra_maps_is_first_in_field(zh->reg->zebra_maps, p->index_type))
+ if (zebra_maps_is_first_in_field(zh->reg->zebra_maps, *p->index_type))
{
/* first in field marker */
p->seqno++;
struct snip_rec_info *h = p->extractCtrl->handle;
ZebraHandle zh = h->zh;
- if (zebra_maps_is_index(zh->reg->zebra_maps, p->index_type))
+ if (zebra_maps_is_index(zh->reg->zebra_maps, *p->index_type))
{
ZebraExplainInfo zei = zh->reg->zei;
int ch = zebraExplain_lookup_attr_str(
zei, zinfo_index_category_index, p->index_type, p->index_name);
- if(zebra_maps_is_complete (h->zh->reg->zebra_maps, p->index_type))
+ if(zebra_maps_is_complete (h->zh->reg->zebra_maps, *p->index_type))
snippet_add_complete_field(p, ch);
else
snippet_add_incomplete_field(p, ch);
ws[i] = NULL;
if (ch < 0)
- ch = zebraExplain_lookup_attr_str(zh->reg->zei, cat, '0', index_name);
+ ch = zebraExplain_lookup_attr_str(zh->reg->zei, cat, "0", index_name);
if (ch < 0)
- ch = zebraExplain_lookup_attr_str(zh->reg->zei, cat, 'p', index_name);
+ ch = zebraExplain_lookup_attr_str(zh->reg->zei, cat, "p", index_name);
if (ch < 0)
- ch = zebraExplain_lookup_attr_str(zh->reg->zei, cat, 'w', index_name);
+ ch = zebraExplain_lookup_attr_str(zh->reg->zei, cat, "w", index_name);
if (ch < 0)
return ;
RecWord word;
extract_init(ctrl, &word);
word.index_name = "_ALLRECORDS";
- word.index_type = 'w';
+ word.index_type = "w";
word.seqno = 1;
extract_add_index_string(&word, zinfo_index_category_alwaysmatches,
"", 0);
char keystr[200]; /* room for zints to print */
char *dst_term = 0;
int ord = CAST_ZINT_TO_INT(key.mem[0]);
- int index_type, i;
+ const char *index_type;
+ int i;
const char *string_index;
zebraExplain_lookup_ord(zh->reg->zei, ord, &index_type,
0/* db */, &string_index);
assert(index_type);
- zebra_term_untrans_iconv(zh, nmem, index_type,
+ zebra_term_untrans_iconv(zh, nmem, *index_type,
&dst_term, str);
*keystr = '\0';
for (i = 0; i<key.len; i++)
{
sprintf(dst_buf + strlen(dst_buf), " %d", str[i] & 0xff);
}
- yaz_log(level, "%s%c %s %s", keystr, index_type,
+ yaz_log(level, "%s%s %s %s", keystr, index_type,
string_index, dst_buf);
}
else
- yaz_log(level, "%s%c %s \"%s\"", keystr, index_type,
+ yaz_log(level, "%s%s %s \"%s\"", keystr, index_type,
string_index, dst_term);
nmem_reset(nmem);
char *dst_term = 0;
int ord;
zint seqno;
- int index_type;
+ const char *index_type;
assert(key.len <= IT_KEY_LEVEL_MAX && key.len > 2);
seqno = key.mem[key.len-1];
zebraExplain_lookup_ord(zh->reg->zei, ord, &index_type,
0/* db */, 0 /* string_index */);
assert(index_type);
- zebra_term_untrans_iconv(zh, nmem, index_type,
+ zebra_term_untrans_iconv(zh, nmem, *index_type,
&dst_term, str);
zebra_snippets_append(snippets, seqno, 0, ord, dst_term);
nmem_reset(nmem);
{
char dst_buf[IT_MAX_WORD];
zint seqno;
- int index_type;
+ const char *index_type;
int ord = CAST_ZINT_TO_INT(key.mem[0]);
const char *db = 0;
assert(key.len <= IT_KEY_LEVEL_MAX && key.len > 2);
seqno = key.mem[key.len-1];
- zebra_term_untrans(zh, index_type, dst_buf, str);
+ zebra_term_untrans(zh, *index_type, dst_buf, str);
yaz_log(YLOG_LOG, "ord=%d seqno=" ZINT_FORMAT
" term=%s", ord, seqno, dst_buf);
if (!p->index_name)
return;
- if (zebra_maps_is_index(zh->reg->zebra_maps, p->index_type))
+ if (zebra_maps_is_index(zh->reg->zebra_maps, *p->index_type))
{
extract_add_index_string(p, zinfo_index_category_index,
string, length);
- if (zebra_maps_is_alwaysmatches(zh->reg->zebra_maps, p->index_type))
+ if (zebra_maps_is_alwaysmatches(zh->reg->zebra_maps, *p->index_type))
{
RecWord word;
memcpy(&word, p, sizeof(word));
&word, zinfo_index_category_alwaysmatches, "", 0);
}
}
- else if (zebra_maps_is_sort(zh->reg->zebra_maps, p->index_type))
+ else if (zebra_maps_is_sort(zh->reg->zebra_maps, *p->index_type))
{
extract_add_sort_string(p, string, length);
}
- else if (zebra_maps_is_staticrank(zh->reg->zebra_maps, p->index_type))
+ else if (zebra_maps_is_staticrank(zh->reg->zebra_maps, *p->index_type))
{
extract_add_staticrank_string(p, string, length);
}
const char **map = 0;
if (remain > 0)
- map = zebra_maps_input(zh->reg->zebra_maps, p->index_type, &b, remain, 0);
+ map = zebra_maps_input(zh->reg->zebra_maps, *p->index_type, &b, remain, 0);
while (map)
{
{
remain = p->term_len - (b - p->term_buf);
if (remain > 0)
- map = zebra_maps_input(zh->reg->zebra_maps, p->index_type, &b,
+ map = zebra_maps_input(zh->reg->zebra_maps, *p->index_type, &b,
remain, 0);
else
map = 0;
buf[i++] = *(cp++);
remain = p->term_len - (b - p->term_buf);
if (remain > 0)
- map = zebra_maps_input(zh->reg->zebra_maps, p->index_type, &b, remain, 0);
+ map = zebra_maps_input(zh->reg->zebra_maps, *p->index_type, &b, remain, 0);
else
map = 0;
}
if (first)
{
first = 0;
- if (zebra_maps_is_first_in_field(zh->reg->zebra_maps, p->index_type))
+ if (zebra_maps_is_first_in_field(zh->reg->zebra_maps, *p->index_type))
{
/* first in field marker */
extract_add_string(p, FIRST_IN_FIELD_STR, FIRST_IN_FIELD_LEN);
int i = 0, remain = p->term_len;
if (remain > 0)
- map = zebra_maps_input(zh->reg->zebra_maps, p->index_type, &b, remain, 1);
+ map = zebra_maps_input(zh->reg->zebra_maps, *p->index_type, &b, remain, 1);
while (remain > 0 && i < IT_MAX_WORD)
{
if (remain > 0)
{
int first = i ? 0 : 1; /* first position */
- map = zebra_maps_input(zh->reg->zebra_maps, p->index_type, &b, remain, first);
+ map = zebra_maps_input(zh->reg->zebra_maps, *p->index_type, &b, remain, first);
}
else
map = 0;
remain = p->term_len - (b - p->term_buf);
if (remain > 0)
{
- map = zebra_maps_input(zh->reg->zebra_maps, p->index_type, &b,
+ map = zebra_maps_input(zh->reg->zebra_maps, *p->index_type, &b,
remain, 0);
}
else
static void extract_token_add2(RecWord *p)
{
- zebra_index_type_t type;
ZebraHandle zh = p->extractCtrl->handle;
- char type_tmp[2];
- type_tmp[0] = p->index_type;
- type_tmp[1] = '\0';
- type = zebra_index_type_get(zh->reg->index_types, type_tmp);
+ zebra_index_type_t type = zebra_index_type_get(zh->reg->index_types, p->index_type);
if (type)
{
if (zebra_index_type_is_index(type))
if (log_level_details)
{
yaz_log(log_level_details, "extract_token_add "
- "type=%c index=%s seqno=" ZINT_FORMAT " s=%.*s",
+ "type=%s index=%s seqno=" ZINT_FORMAT " s=%.*s",
p->index_type, p->index_name,
p->seqno, p->term_len, p->term_buf);
}
- if ((wrbuf = zebra_replace(zh->reg->zebra_maps, p->index_type, 0,
+ if ((wrbuf = zebra_replace(zh->reg->zebra_maps, *p->index_type, 0,
p->term_buf, p->term_len)))
{
p->term_buf = wrbuf_buf(wrbuf);
p->term_len = wrbuf_len(wrbuf);
}
- if (zebra_maps_is_complete(zh->reg->zebra_maps, p->index_type))
+ if (zebra_maps_is_complete(zh->reg->zebra_maps, *p->index_type))
extract_add_complete_field(p);
else
extract_add_incomplete_field(p);
-/* $Id: index.h,v 1.201 2007-10-29 09:25:40 adam Exp $
+/* $Id: index.h,v 1.202 2007-10-29 16:57:52 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
const char *term, int length_term, const char *flags,
int preserve_position, int term_type, NMEM rset_nmem,
struct rset_key_control *kctrl, int scope,
- struct ord_list *ol, int reg_type,
+ struct ord_list *ol, const char *index_type,
zint hits_limit, const char *term_ref_id);
void resultSetAddTerm(ZebraHandle zh, ZebraSet s, int reg_type,
ZEBRA_RES zebra_apt_get_ord(ZebraHandle zh,
Z_AttributesPlusTerm *zapt,
- int index_type,
+ const char *index_type,
const char *xpath_use,
const Odr_oid *curAttributeSet,
int *ord);
ZEBRA_RES zebra_attr_list_get_ord(ZebraHandle zh,
Z_AttributeList *attr_list,
zinfo_index_category_t cat,
- int index_type,
+ const char *index_type,
const Odr_oid *curAttributeSet,
int *ord);
-/* $Id: invstat.c,v 1.54 2007-01-15 15:10:16 adam Exp $
+/* $Id: invstat.c,v 1.55 2007-10-29 16:57:52 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
char dst[IT_MAX_WORD+1];
int ord;
int len = key_SU_decode(&ord, (const unsigned char *) s);
- int index_type;
+ const char *index_type;
const char *db = 0;
if (!zh)
{
zebraExplain_lookup_ord (zh->reg->zei, ord, &index_type, &db, 0);
- zebra_term_untrans(zh, index_type, dst, s + len);
+ zebra_term_untrans(zh, *index_type, dst, s + len);
}
printf("%02d:%10" ZINT_FORMAT0 " %s %d.%d - %d.%d\n", ord, count, dst,
firstsys, firstseq, lastsys, lastseq);
-/* $Id: kinput.c,v 1.84 2007-10-29 09:25:40 adam Exp $
+/* $Id: kinput.c,v 1.85 2007-10-29 16:57:52 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
char dst[IT_MAX_WORD+1];
int ord;
int len = key_SU_decode(&ord, (const unsigned char *) s);
- int index_type;
+ const char *index_type;
if (!zh)
yaz_log(YLOG_LOG, "ord=%d", ord);
zebraExplain_lookup_ord(zh->reg->zei,
ord, &index_type, &db, &string_index);
- zebra_term_untrans(zh, index_type, dst, s + len);
+ zebra_term_untrans(zh, *index_type, dst, s + len);
- yaz_log(YLOG_LOG, "ord=%d index_type=%c index=%s term=%s",
+ yaz_log(YLOG_LOG, "ord=%d index_type=%s index=%s term=%s",
ord, index_type, string_index, dst);
}
}
-/* $Id: mod_dom.c,v 1.40 2007-10-21 19:39:00 adam Exp $
+/* $Id: mod_dom.c,v 1.41 2007-10-29 16:57:52 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
recword->index_name = (const char *)index;
if (type && *type)
- recword->index_type = *type;
+ recword->index_type = (const char *) type;
/* writing debug out */
if (extctr->flagShowRecords)
type ? (const char *) type : "null",
text ? (const char *) text : "null");
- /* actually indexing the text given */
- recword->index_name = (const char *)index;
- if (type && *type)
- recword->index_type = *type;
(extctr->tokenAdd)(recword);
/* eat whitespaces */
-/* $Id: ranksimilarity.c,v 1.12 2007-01-15 15:10:16 adam Exp $
+/* $Id: ranksimilarity.c,v 1.13 2007-10-29 16:57:52 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
for (; ol; ol = ol->next)
{
- int index_type = 0;
+ const char *index_type = 0;
const char *db = 0;
const char *string_index = 0;
+= zebraExplain_ord_get_term_occurrences(reg->zei, ol->ord);
if (string_index)
- yaz_log(log_level,
- "begin() index: ord=%d type=%c db=%s str-index=%s",
- ol->ord, index_type, db, string_index);
+ yaz_log(log_level,
+ "begin() index: ord=%d type=%s db=%s str-index=%s",
+ ol->ord, index_type, db, string_index);
else
- yaz_log(log_level,
- "begin() index: ord=%d type=%c db=%s",
- ol->ord, index_type, db);
+ yaz_log(log_level,
+ "begin() index: ord=%d type=%s db=%s",
+ ol->ord, index_type, db);
}
si->entries[i].no_docs_fieldindex = no_docs_fieldindex;
-/* $Id: rankstatic.c,v 1.10 2007-01-15 15:10:16 adam Exp $
+/* $Id: rankstatic.c,v 1.11 2007-10-29 16:57:52 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
for (; ol; ol = ol->next)
{
- int index_type = 0;
+ const char *index_type = 0;
const char *db = 0;
const char *string_index = 0;
int set = -1;
ol->ord, &index_type, &db, &string_index);
if (string_index)
- yaz_log(log_level, " ord=%d index_type=%c db=%s str-index=%s",
- ol->ord, index_type, db, string_index);
+ yaz_log(log_level, " ord=%d index_type=%s db=%s str-index=%s",
+ ol->ord, index_type, db, string_index);
else
- yaz_log(log_level, " ord=%d index_type=%c db=%s set=%d use=%d",
- ol->ord, index_type, db, set, use);
+ yaz_log(log_level, " ord=%d index_type=%s db=%s set=%d use=%d",
+ ol->ord, index_type, db, set, use);
}
if (!strncmp (terms[i]->flags, "rank,", 5))
(si->no_rank_entries)++;
-/* $Id: recgrs.c,v 1.20 2007-10-29 09:25:40 adam Exp $
+/* $Id: recgrs.c,v 1.21 2007-10-29 16:57:52 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
RecWord *wrd)
{
wrd->index_name = ZEBRA_XPATH_ELM_BEGIN;
- wrd->index_type = '0';
+ wrd->index_type = "0";
wrd->term_buf = tag_path;
wrd->term_len = strlen(tag_path);
(*p->tokenAdd)(wrd);
if (value) {
wrd->index_name = ZEBRA_XPATH_ATTR_CDATA;
- wrd->index_type = 'w';
+ wrd->index_type = "w";
wrd->term_buf = value;
wrd->term_len = strlen(value);
(*p->tokenAdd)(wrd);
}
wrd->index_name = ZEBRA_XPATH_ELM_END;
- wrd->index_type = '0';
+ wrd->index_type = "0";
wrd->term_buf = tag_path;
wrd->term_len = strlen(tag_path);
(*p->tokenAdd)(wrd);
{
/* need to copy recword because it may be changed */
RecWord wrd_tl;
- wrd->index_type = *tl->structure;
+ wrd->index_type = tl->structure;
memcpy(&wrd_tl, wrd, sizeof(*wrd));
if (tl->source)
sp_parse(sp, n, &wrd_tl, tl->source);
if (!p->flagShowRecords && !termlist_only)
{
wrd->index_name = xpath_index;
- wrd->index_type = 'w';
+ wrd->index_type = "w";
(*p->tokenAdd)(wrd);
}
break;
case DATA1N_tag:
mk_tag_path_full(tag_path_full, sizeof(tag_path_full), n);
- wrd->index_type = '0';
+ wrd->index_type = "0";
wrd->term_buf = tag_path_full;
wrd->term_len = strlen(tag_path_full);
wrd->index_name = xpath_index;
if (!termlist_only)
{
/* attribute (no value) */
- wrd->index_type = '0';
+ wrd->index_type = "0";
wrd->index_name = ZEBRA_XPATH_ATTR_NAME;
wrd->term_buf = xp->name;
wrd->term_len = strlen(xp->name);
strcat(comb, xp->value);
wrd->index_name = ZEBRA_XPATH_ATTR_NAME;
- wrd->index_type = '0';
+ wrd->index_type = "0";
wrd->term_buf = comb;
wrd->term_len = strlen(comb);
wrd->seqno--;
if (xp->value)
{
wrd->index_name = tl->index_name;
- wrd->index_type = *tl->structure;
+ wrd->index_type = tl->structure;
wrd->term_buf = xp->value;
wrd->term_len = strlen(xp->value);
(*p->tokenAdd)(wrd);
}
else
{
- wrd->index_type = *tlist->structure;
+ wrd->index_type = tlist->structure;
wrd->index_name = tlist->index_name;
(*p->tokenAdd)(wrd);
}
-/* $Id: retrieve.c,v 1.73 2007-10-29 09:25:40 adam Exp $
+/* $Id: retrieve.c,v 1.74 2007-10-29 16:57:53 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
const char *retrieval_type;
size_t retrieval_type_len;
char retrieval_index_cstr[256];
+ char retrieval_type_cstr[256];
int ord;
/* only accept XML and SUTRS requests */
memcpy(retrieval_index_cstr, retrieval_index, retrieval_index_len);
retrieval_index_cstr[retrieval_index_len] = '\0';
+ memcpy(retrieval_type_cstr, retrieval_type, retrieval_type_len);
+ retrieval_type_cstr[retrieval_type_len] = '\0';
+
ord = zebraExplain_lookup_attr_str(zh->reg->zei,
zinfo_index_category_sort,
- retrieval_type[0],
+ retrieval_type_cstr,
retrieval_index_cstr);
if (ord == -1)
return -1; /* is not a sort index */
{
char dst_buf[IT_MAX_WORD];
char str[IT_MAX_WORD];
- int index_type;
+ const char *index_type;
const char *db = 0;
const char *string_index = 0;
WRBUF wrbuf = wrbuf_alloc();
zebraExplain_lookup_ord(zh->reg->zei, ord, &index_type, &db, &string_index);
- zebra_term_untrans(zh, index_type, dst_buf, str);
-
+ zebra_term_untrans(zh, *index_type, dst_buf, str);
if (!oid_oidcmp(input_format, yaz_oid_recsyn_xml))
{
wrbuf_printf(wrbuf, " <index name=\"%s\"",
string_index);
- wrbuf_printf(wrbuf, " type=\"%c\">", index_type);
+ wrbuf_printf(wrbuf, " type=\"%s\">", index_type);
wrbuf_xmlputs(wrbuf, dst_buf);
wrbuf_printf(wrbuf, "</index>\n");
wrbuf_printf(wrbuf, "</record>\n");
{
*output_format = yaz_oid_recsyn_sutrs;
- wrbuf_printf(wrbuf, "%s %c %s\n", string_index, index_type,
+ wrbuf_printf(wrbuf, "%s %s %s\n", string_index, index_type,
dst_buf);
}
*rec_lenp = wrbuf_len(wrbuf);
size_t retrieval_type_len;
zebra_rec_keys_t keys;
int ret_code = 0;
+ char retrieval_type_cstr[256];
/* set output variables before processing possible error states */
/* *rec_lenp = 0; */
&retrieval_type, &retrieval_type_len))
return YAZ_BIB1_SPECIFIED_ELEMENT_SET_NAME_NOT_VALID_FOR_SPECIFIED_;
- if (retrieval_type_len != 0 && retrieval_type_len != 1)
+ if (retrieval_type_len)
{
- return YAZ_BIB1_SPECIFIED_ELEMENT_SET_NAME_NOT_VALID_FOR_SPECIFIED_;
+ memcpy(retrieval_type_cstr, retrieval_type, retrieval_type_len);
+ retrieval_type_cstr[retrieval_type_len] = '\0';
}
-
+
if (retrieval_index_len)
{
char retrieval_index_cstr[256];
if (zebraExplain_lookup_attr_str(zh->reg->zei,
zinfo_index_category_index,
- (retrieval_type_len == 0 ? -1 :
- retrieval_type[0]),
+ (retrieval_type_len == 0 ? 0 :
+ retrieval_type_cstr),
retrieval_index_cstr) == -1)
return YAZ_BIB1_SPECIFIED_ELEMENT_SET_NAME_NOT_VALID_FOR_SPECIFIED_;
}
{
int i;
int ord = CAST_ZINT_TO_INT(key_in.mem[0]);
- int index_type;
+ const char *index_type;
const char *db = 0;
const char *string_index = 0;
size_t string_index_len;
{
/* process only if type is not defined, or is matching */
if (retrieval_type == 0
- || (retrieval_type_len == 1
- && retrieval_type[0] == index_type))
+ || !strcmp(retrieval_type_cstr, index_type))
{
- zebra_term_untrans(zh, index_type, dst_buf, str);
+ zebra_term_untrans(zh, *index_type, dst_buf, str);
if (strlen(dst_buf))
{
if (!oid_oidcmp(input_format, yaz_oid_recsyn_xml))
wrbuf_printf(wrbuf, " <index name=\"%s\"",
string_index);
- wrbuf_printf(wrbuf, " type=\"%c\"", index_type);
+ wrbuf_printf(wrbuf, " type=\"%s\"", index_type);
wrbuf_printf(wrbuf, " seq=\"" ZINT_FORMAT "\">",
key_in.mem[key_in.len -1]);
{
wrbuf_printf(wrbuf, "%s ", string_index);
- wrbuf_printf(wrbuf, "%c", index_type);
+ wrbuf_printf(wrbuf, "%s", index_type);
for (i = 1; i < key_in.len; i++)
wrbuf_printf(wrbuf, " " ZINT_FORMAT,
{
if (doc_w->mark)
{
- int index_type;
+ const char *index_type;
const char *db = 0;
const char *string_index = 0;
if (mark_state == 0)
{
wrbuf_printf(wrbuf, " <snippet name=\"%s\"", string_index);
- wrbuf_printf(wrbuf, " type=\"%c\">", index_type);
+ wrbuf_printf(wrbuf, " type=\"%s\">", index_type);
}
if (doc_w->match)
wrbuf_puts(wrbuf, "<s>");
-/* $Id: rpnscan.c,v 1.14 2007-10-29 09:25:40 adam Exp $
+/* $Id: rpnscan.c,v 1.15 2007-10-29 16:57:53 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
/* convert APT SCAN term to internal cmap */
static ZEBRA_RES trans_scan_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
- char *termz, int reg_type)
+ char *termz, const char *index_type)
{
char termz0[IT_MAX_WORD];
while ((len = (cp_end - cp)) > 0)
{
- map = zebra_maps_input(zh->reg->zebra_maps, reg_type, &cp, len, 0);
+ map = zebra_maps_input(zh->reg->zebra_maps, *index_type,
+ &cp, len, 0);
if (**map == *CHR_SPACE)
space_map = *map;
else
Z_AttributesPlusTerm *zapt,
RSET limit_set,
const char *term,
- int index_type,
+ const char *index_type,
struct scan2_info_entry *ar, int ord_no,
ZebraScanEntry *glist, int pos)
{
}
}
if (!glist[pos].term)
- zebra_term_untrans_iconv(zh, stream->mem, index_type,
+ zebra_term_untrans_iconv(zh, stream->mem, *index_type,
&glist[pos].term, term);
glist[pos].occurrences = count;
zebra_snippets_destroy(rec_snippets);
int *position, int *num_entries,
ZebraScanEntry **list,
int *is_partial, RSET limit_set,
- int index_type, int ord_no, int *ords)
+ const char *index_type,
+ int ord_no, int *ords)
{
struct scan2_info_entry *ar = nmem_malloc(nmem, sizeof(*ar) * ord_no);
struct rpn_char_map_info rcmi;
*num_entries = 0;
return ZEBRA_OK;
}
- rpn_char_map_prepare(zh->reg, index_type, &rcmi);
+ rpn_char_map_prepare(zh->reg, *index_type, &rcmi);
for (i = 0; i < ord_no; i++)
ar[i].term = wrbuf_alloc();
int base_no;
int ords[RPN_MAX_ORDS], ord_no = 0;
- unsigned index_type;
+ const char *index_type;
char *search_type = NULL;
char rank_type[128];
int complete_flag;
-/* $Id: rpnsearch.c,v 1.15 2007-10-29 09:25:41 adam Exp $
+/* $Id: rpnsearch.c,v 1.16 2007-10-29 16:57:53 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
}
/* term_100: handle term, where trunc = none(no operators at all) */
-static int term_100(ZebraMaps zebra_maps, int reg_type,
+static int term_100(ZebraMaps zebra_maps, const char *index_type,
const char **src, WRBUF term_dict, int space_split,
char *dst_term)
{
const char *space_start = 0;
const char *space_end = 0;
- if (!term_pre(zebra_maps, reg_type, src, NULL, NULL, !space_split))
+ if (!term_pre(zebra_maps, *index_type, src, NULL, NULL, !space_split))
return 0;
s0 = *src;
while (*s0)
{
const char *s1 = s0;
int q_map_match = 0;
- map = zebra_maps_search(zebra_maps, reg_type, &s0, strlen(s0),
+ map = zebra_maps_search(zebra_maps, *index_type, &s0, strlen(s0),
&q_map_match);
if (space_split)
{
}
/* term_101: handle term, where trunc = Process # */
-static int term_101(ZebraMaps zebra_maps, int reg_type,
+static int term_101(ZebraMaps zebra_maps, const char *index_type,
const char **src, WRBUF term_dict, int space_split,
char *dst_term)
{
int i = 0;
int j = 0;
- if (!term_pre(zebra_maps, reg_type, src, "#", "#", !space_split))
+ if (!term_pre(zebra_maps, *index_type, src, "#", "#", !space_split))
return 0;
s0 = *src;
while (*s0)
{
const char *s1 = s0;
int q_map_match = 0;
- map = zebra_maps_search(zebra_maps, reg_type, &s0, strlen(s0),
+ map = zebra_maps_search(zebra_maps, *index_type, &s0, strlen(s0),
&q_map_match);
if (space_split && **map == *CHR_SPACE)
break;
}
/* term_103: handle term, where trunc = re-2 (regular expressions) */
-static int term_103(ZebraMaps zebra_maps, int reg_type, const char **src,
+static int term_103(ZebraMaps zebra_maps, const char *index_type,
+ const char **src,
WRBUF term_dict, int *errors, int space_split,
char *dst_term)
{
const char *s0;
const char **map;
- if (!term_pre(zebra_maps, reg_type, src, "^\\()[].*+?|", "(", !space_split))
+ if (!term_pre(zebra_maps, *index_type, src, "^\\()[].*+?|", "(", !space_split))
return 0;
s0 = *src;
if (errors && *s0 == '+' && s0[1] && s0[2] == '+' && s0[3] &&
{
const char *s1 = s0;
int q_map_match = 0;
- map = zebra_maps_search(zebra_maps, reg_type, &s0, strlen(s0),
+ map = zebra_maps_search(zebra_maps, *index_type, &s0, strlen(s0),
&q_map_match);
if (space_split && **map == *CHR_SPACE)
break;
}
/* term_103: handle term, where trunc = re-1 (regular expressions) */
-static int term_102(ZebraMaps zebra_maps, int reg_type, const char **src,
+static int term_102(ZebraMaps zebra_maps, const char *index_type,
+ const char **src,
WRBUF term_dict, int space_split, char *dst_term)
{
- return term_103(zebra_maps, reg_type, src, term_dict, NULL, space_split,
+ return term_103(zebra_maps, index_type, src, term_dict, NULL, space_split,
dst_term);
}
/* term_104: handle term, process # and ! */
-static int term_104(ZebraMaps zebra_maps, int reg_type,
+static int term_104(ZebraMaps zebra_maps, const char *index_type,
const char **src, WRBUF term_dict, int space_split,
char *dst_term)
{
int i = 0;
int j = 0;
- if (!term_pre(zebra_maps, reg_type, src, "?*#", "?*#", !space_split))
+ if (!term_pre(zebra_maps, *index_type, src, "?*#", "?*#", !space_split))
return 0;
s0 = *src;
while (*s0)
{
const char *s1 = s0;
int q_map_match = 0;
- map = zebra_maps_search(zebra_maps, reg_type, &s0, strlen(s0),
+ map = zebra_maps_search(zebra_maps, *index_type, &s0, strlen(s0),
&q_map_match);
if (space_split && **map == *CHR_SPACE)
break;
}
/* term_105/106: handle term, where trunc = Process * and ! and right trunc */
-static int term_105(ZebraMaps zebra_maps, int reg_type,
+static int term_105(ZebraMaps zebra_maps, const char *index_type,
const char **src, WRBUF term_dict, int space_split,
char *dst_term, int right_truncate)
{
int i = 0;
int j = 0;
- if (!term_pre(zebra_maps, reg_type, src, "*!", "*!", !space_split))
+ if (!term_pre(zebra_maps, *index_type, src, "*!", "*!", !space_split))
return 0;
s0 = *src;
while (*s0)
{
const char *s1 = s0;
int q_map_match = 0;
- map = zebra_maps_search(zebra_maps, reg_type, &s0, strlen(s0),
+ map = zebra_maps_search(zebra_maps, *index_type, &s0, strlen(s0),
&q_map_match);
if (space_split && **map == *CHR_SPACE)
break;
static int string_relation(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
const char **term_sub, WRBUF term_dict,
const Odr_oid *attributeSet,
- int reg_type, int space_split, char *term_dst,
+ const char *index_type, int space_split, char *term_dst,
int *error_code)
{
AttrType relation;
switch (relation_value)
{
case 1:
- if (!term_100(zh->reg->zebra_maps, reg_type,
+ if (!term_100(zh->reg->zebra_maps, index_type,
term_sub, term_component,
space_split, term_dst))
{
wrbuf_putc(term_dict, ')');
break;
case 2:
- if (!term_100(zh->reg->zebra_maps, reg_type,
+ if (!term_100(zh->reg->zebra_maps, index_type,
term_sub, term_component,
space_split, term_dst))
{
wrbuf_putc(term_dict, ')');
break;
case 5:
- if (!term_100(zh->reg->zebra_maps, reg_type,
+ if (!term_100(zh->reg->zebra_maps, index_type,
term_sub, term_component, space_split, term_dst))
{
wrbuf_destroy(term_component);
wrbuf_putc(term_dict, ')');
break;
case 4:
- if (!term_100(zh->reg->zebra_maps, reg_type, term_sub,
+ if (!term_100(zh->reg->zebra_maps, index_type, term_sub,
term_component, space_split, term_dst))
{
wrbuf_destroy(term_component);
if (!**term_sub)
return 1;
yaz_log(log_level_rpn, "Relation =");
- if (!term_100(zh->reg->zebra_maps, reg_type, term_sub,
+ if (!term_100(zh->reg->zebra_maps, index_type, term_sub,
term_component, space_split, term_dst))
{
wrbuf_destroy(term_component);
WRBUF term_dict,
const Odr_oid *attributeSet, NMEM stream,
struct grep_info *grep_info,
- int reg_type, int complete_flag,
+ const char *index_type, int complete_flag,
int num_bases, char **basenames,
char *term_dst,
const char *xpath_use,
const char **term_sub,
const Odr_oid *attributeSet, NMEM stream,
struct grep_info *grep_info,
- int reg_type, int complete_flag,
+ const char *index_type, int complete_flag,
int num_bases, char **basenames,
char *term_dst,
const char *rank_type,
grep_info->isam_p_indx = 0;
res = string_term(zh, zapt, term_sub, term_dict,
attributeSet, stream, grep_info,
- reg_type, complete_flag, num_bases, basenames,
+ index_type, complete_flag, num_bases, basenames,
term_dst, xpath_use, &ol);
wrbuf_destroy(term_dict);
if (res != ZEBRA_OK)
grep_info->isam_p_indx, term_dst,
strlen(term_dst), rank_type, 1 /* preserve pos */,
zapt->term->which, rset_nmem,
- kc, kc->scope, ol, reg_type, hits_limit_value,
+ kc, kc->scope, ol, index_type, hits_limit_value,
term_ref_id_str);
if (!*rset)
return ZEBRA_FAIL;
WRBUF term_dict,
const Odr_oid *attributeSet, NMEM stream,
struct grep_info *grep_info,
- int reg_type, int complete_flag,
+ const char *index_type, int complete_flag,
int num_bases, char **basenames,
char *term_dst,
const char *xpath_use,
*ol = ord_list_create(stream);
- rpn_char_map_prepare(zh->reg, reg_type, &rcmi);
+ rpn_char_map_prepare(zh->reg, *index_type, &rcmi);
attr_init_APT(&truncation, zapt, 5);
truncation_value = attr_find(&truncation, NULL);
yaz_log(log_level_rpn, "truncation value %d", truncation_value);
return ZEBRA_FAIL;
}
- if (zebra_apt_get_ord(zh, zapt, reg_type, xpath_use,
+ if (zebra_apt_get_ord(zh, zapt, index_type, xpath_use,
attributeSet, &ord) != ZEBRA_OK)
continue;
case 100: /* do not truncate */
if (!string_relation(zh, zapt, &termp, term_dict,
attributeSet,
- reg_type, space_split, term_dst,
+ index_type, space_split, term_dst,
&relation_error))
{
if (relation_error)
break;
case 1: /* right truncation */
wrbuf_putc(term_dict, '(');
- if (!term_100(zh->reg->zebra_maps, reg_type,
+ if (!term_100(zh->reg->zebra_maps, index_type,
&termp, term_dict, space_split, term_dst))
{
*term_sub = 0;
break;
case 2: /* keft truncation */
wrbuf_puts(term_dict, "(.*");
- if (!term_100(zh->reg->zebra_maps, reg_type,
+ if (!term_100(zh->reg->zebra_maps, index_type,
&termp, term_dict, space_split, term_dst))
{
*term_sub = 0;
break;
case 3: /* left&right truncation */
wrbuf_puts(term_dict, "(.*");
- if (!term_100(zh->reg->zebra_maps, reg_type,
+ if (!term_100(zh->reg->zebra_maps, index_type,
&termp, term_dict, space_split, term_dst))
{
*term_sub = 0;
break;
case 101: /* process # in term */
wrbuf_putc(term_dict, '(');
- if (!term_101(zh->reg->zebra_maps, reg_type,
+ if (!term_101(zh->reg->zebra_maps, index_type,
&termp, term_dict, space_split, term_dst))
{
*term_sub = 0;
break;
case 102: /* Regexp-1 */
wrbuf_putc(term_dict, '(');
- if (!term_102(zh->reg->zebra_maps, reg_type,
+ if (!term_102(zh->reg->zebra_maps, index_type,
&termp, term_dict, space_split, term_dst))
{
*term_sub = 0;
case 103: /* Regexp-2 */
regex_range = 1;
wrbuf_putc(term_dict, '(');
- if (!term_103(zh->reg->zebra_maps, reg_type,
+ if (!term_103(zh->reg->zebra_maps, index_type,
&termp, term_dict, ®ex_range,
space_split, term_dst))
{
break;
case 104: /* process # and ! in term */
wrbuf_putc(term_dict, '(');
- if (!term_104(zh->reg->zebra_maps, reg_type,
+ if (!term_104(zh->reg->zebra_maps, index_type,
&termp, term_dict, space_split, term_dst))
{
*term_sub = 0;
break;
case 105: /* process * and ! in term */
wrbuf_putc(term_dict, '(');
- if (!term_105(zh->reg->zebra_maps, reg_type,
+ if (!term_105(zh->reg->zebra_maps, index_type,
&termp, term_dict, space_split, term_dst, 1))
{
*term_sub = 0;
break;
case 106: /* process * and ! in term */
wrbuf_putc(term_dict, '(');
- if (!term_105(zh->reg->zebra_maps, reg_type,
+ if (!term_105(zh->reg->zebra_maps, index_type,
&termp, term_dict, space_split, term_dst, 0))
{
*term_sub = 0;
const char *termz,
const Odr_oid *attributeSet,
NMEM stream,
- int reg_type, int complete_flag,
+ const char *index_type, int complete_flag,
const char *rank_type,
const char *xpath_use,
int num_bases, char **basenames,
*num_result_sets = 0;
*term_dst = 0;
- if (grep_info_prepare(zh, zapt, &grep_info, reg_type) == ZEBRA_FAIL)
+ if (grep_info_prepare(zh, zapt, &grep_info, *index_type) == ZEBRA_FAIL)
return ZEBRA_FAIL;
while(1)
{
}
res = term_trunc(zh, zapt, &termp, attributeSet,
stream, &grep_info,
- reg_type, complete_flag,
+ index_type, complete_flag,
num_bases, basenames,
term_dst, rank_type,
xpath_use, rset_nmem,
static ZEBRA_RES rpn_search_APT_position(ZebraHandle zh,
Z_AttributesPlusTerm *zapt,
const Odr_oid *attributeSet,
- int reg_type,
+ const char *index_type,
int num_bases, char **basenames,
NMEM rset_nmem,
RSET *rset,
return ZEBRA_FAIL;
}
- if (!zebra_maps_is_first_in_field(zh->reg->zebra_maps, reg_type))
+ if (!zebra_maps_is_first_in_field(zh->reg->zebra_maps, *index_type))
{
zebra_setError_zint(zh, YAZ_BIB1_UNSUPP_POSITION_ATTRIBUTE,
position_value);
return ZEBRA_FAIL;
}
- if (zebra_apt_get_ord(zh, zapt, reg_type, 0,
+ if (zebra_apt_get_ord(zh, zapt, index_type, 0,
attributeSet, &ord) != ZEBRA_OK)
continue;
const char *termz_org,
const Odr_oid *attributeSet,
NMEM stream,
- int reg_type, int complete_flag,
+ const char *index_type, int complete_flag,
const char *rank_type,
const char *xpath_use,
int num_bases, char **basenames,
int num_result_sets = 0;
ZEBRA_RES res =
term_list_trunc(zh, zapt, termz_org, attributeSet,
- stream, reg_type, complete_flag,
+ stream, index_type, complete_flag,
rank_type, xpath_use,
num_bases, basenames,
rset_nmem,
{
RSET first_set = 0;
res = rpn_search_APT_position(zh, zapt, attributeSet,
- reg_type,
+ index_type,
num_bases, basenames,
rset_nmem, &first_set,
kc);
const char *termz_org,
const Odr_oid *attributeSet,
NMEM stream,
- int reg_type, int complete_flag,
+ const char *index_type,
+ int complete_flag,
const char *rank_type,
const char *xpath_use,
int num_bases, char **basenames,
int i;
ZEBRA_RES res =
term_list_trunc(zh, zapt, termz_org, attributeSet,
- stream, reg_type, complete_flag,
+ stream, index_type, complete_flag,
rank_type, xpath_use,
num_bases, basenames,
rset_nmem,
{
RSET first_set = 0;
res = rpn_search_APT_position(zh, zapt, attributeSet,
- reg_type,
+ index_type,
num_bases, basenames,
rset_nmem, &first_set,
kc);
const char *termz_org,
const Odr_oid *attributeSet,
NMEM stream,
- int reg_type, int complete_flag,
+ const char *index_type,
+ int complete_flag,
const char *rank_type,
const char *xpath_use,
int num_bases, char **basenames,
int i;
ZEBRA_RES res =
term_list_trunc(zh, zapt, termz_org, attributeSet,
- stream, reg_type, complete_flag,
+ stream, index_type, complete_flag,
rank_type, xpath_use,
num_bases, basenames,
rset_nmem,
{
RSET first_set = 0;
res = rpn_search_APT_position(zh, zapt, attributeSet,
- reg_type,
+ index_type,
num_bases, basenames,
rset_nmem, &first_set,
kc);
const Odr_oid *attributeSet,
struct grep_info *grep_info,
int *max_pos,
- int reg_type,
+ const char *index_type,
char *term_dst,
int *error_code)
{
{
case 1:
yaz_log(log_level_rpn, "Relation <");
- if (!term_100(zh->reg->zebra_maps, reg_type, term_sub, term_num, 1,
+ if (!term_100(zh->reg->zebra_maps, index_type, term_sub, term_num, 1,
term_dst))
{
wrbuf_destroy(term_num);
break;
case 2:
yaz_log(log_level_rpn, "Relation <=");
- if (!term_100(zh->reg->zebra_maps, reg_type, term_sub, term_num, 1,
+ if (!term_100(zh->reg->zebra_maps, index_type, term_sub, term_num, 1,
term_dst))
{
wrbuf_destroy(term_num);
break;
case 4:
yaz_log(log_level_rpn, "Relation >=");
- if (!term_100(zh->reg->zebra_maps, reg_type, term_sub, term_num, 1,
+ if (!term_100(zh->reg->zebra_maps, index_type, term_sub, term_num, 1,
term_dst))
{
wrbuf_destroy(term_num);
break;
case 5:
yaz_log(log_level_rpn, "Relation >");
- if (!term_100(zh->reg->zebra_maps, reg_type, term_sub, term_num, 1,
+ if (!term_100(zh->reg->zebra_maps, index_type, term_sub, term_num, 1,
term_dst))
{
wrbuf_destroy(term_num);
case -1:
case 3:
yaz_log(log_level_rpn, "Relation =");
- if (!term_100(zh->reg->zebra_maps, reg_type, term_sub, term_num, 1,
+ if (!term_100(zh->reg->zebra_maps, index_type, term_sub, term_num, 1,
term_dst))
{
wrbuf_destroy(term_num);
WRBUF term_dict,
const Odr_oid *attributeSet, NMEM stream,
struct grep_info *grep_info,
- int reg_type, int complete_flag,
+ const char *index_type, int complete_flag,
int num_bases, char **basenames,
char *term_dst,
const char *xpath_use,
*ol = ord_list_create(stream);
- rpn_char_map_prepare(zh->reg, reg_type, &rcmi);
+ rpn_char_map_prepare(zh->reg, *index_type, &rcmi);
for (base_no = 0; base_no < num_bases; base_no++)
{
return ZEBRA_FAIL;
}
- if (zebra_apt_get_ord(zh, zapt, reg_type, xpath_use,
+ if (zebra_apt_get_ord(zh, zapt, index_type, xpath_use,
attributeSet, &ord) != ZEBRA_OK)
continue;
bases_ok++;
wrbuf_putc(term_dict, ')');
if (!numeric_relation(zh, zapt, &termp, term_dict,
- attributeSet, grep_info, &max_pos, reg_type,
+ attributeSet, grep_info, &max_pos, index_type,
term_dst, &relation_error))
{
if (relation_error)
const char *termz,
const Odr_oid *attributeSet,
NMEM stream,
- int reg_type, int complete_flag,
+ const char *index_type,
+ int complete_flag,
const char *rank_type,
const char *xpath_use,
int num_bases, char **basenames,
term_limits_APT(zh, zapt, &hits_limit_value, &term_ref_id_str, stream);
yaz_log(log_level_rpn, "APT_numeric t='%s'", termz);
- if (grep_info_prepare(zh, zapt, &grep_info, reg_type) == ZEBRA_FAIL)
+ if (grep_info_prepare(zh, zapt, &grep_info, *index_type) == ZEBRA_FAIL)
return ZEBRA_FAIL;
while (1)
{
grep_info.isam_p_indx = 0;
res = numeric_term(zh, zapt, &termp, term_dict,
attributeSet, stream, &grep_info,
- reg_type, complete_flag, num_bases, basenames,
+ index_type, complete_flag, num_bases, basenames,
term_dst, xpath_use, &ol);
wrbuf_destroy(term_dict);
if (res == ZEBRA_FAIL || termp == 0)
strlen(term_dst), rank_type,
0 /* preserve position */,
zapt->term->which, rset_nmem,
- kc, kc->scope, ol, reg_type,
+ kc, kc->scope, ol, index_type,
hits_limit_value,
term_ref_id_str);
if (!result_sets[num_result_sets])
static RSET xpath_trunc(ZebraHandle zh, NMEM stream,
- int reg_type, const char *term,
+ const char *index_type, const char *term,
const char *xpath_use,
NMEM rset_nmem,
struct rset_key_control *kc)
struct grep_info grep_info;
int ord = zebraExplain_lookup_attr_str(zh->reg->zei,
zinfo_index_category_index,
- reg_type, xpath_use);
+ index_type, xpath_use);
if (grep_info_prepare(zh, 0 /* zapt */, &grep_info, '0') == ZEBRA_FAIL)
return rset_create_null(rset_nmem, kc, 0);
rset = rset_trunc(zh, grep_info.isam_p_buf,
grep_info.isam_p_indx, term, strlen(term),
flags, 1, term_type, rset_nmem,
- kc, kc->scope, 0, reg_type, 0 /* hits_limit */,
+ kc, kc->scope, 0, index_type, 0 /* hits_limit */,
0 /* term_ref_id_str */);
grep_info_delete(&grep_info);
wrbuf_destroy(term_dict);
}
}
rset_attr = xpath_trunc(
- zh, stream, '0', wrbuf_cstr(wbuf), ZEBRA_XPATH_ATTR_NAME,
+ zh, stream, "0", wrbuf_cstr(wbuf),
+ ZEBRA_XPATH_ATTR_NAME,
rset_nmem, kc);
wrbuf_destroy(wbuf);
}
wrbuf_cstr(xpath_rev));
if (wrbuf_len(xpath_rev))
{
- rset_start_tag = xpath_trunc(zh, stream, '0',
+ rset_start_tag = xpath_trunc(zh, stream, "0",
wrbuf_cstr(xpath_rev),
ZEBRA_XPATH_ELM_BEGIN,
rset_nmem, kc);
rset = rset_start_tag;
else
{
- rset_end_tag = xpath_trunc(zh, stream, '0',
+ rset_end_tag = xpath_trunc(zh, stream, "0",
wrbuf_cstr(xpath_rev),
ZEBRA_XPATH_ELM_END,
rset_nmem, kc);
#define MAX_XPATH_STEPS 10
+static ZEBRA_RES rpn_search_database(ZebraHandle zh,
+ Z_AttributesPlusTerm *zapt,
+ const Odr_oid *attributeSet, NMEM stream,
+ Z_SortKeySpecList *sort_sequence,
+ int num_bases, char **basenames,
+ NMEM rset_nmem,
+ RSET *rset,
+ struct rset_key_control *kc);
+
static ZEBRA_RES rpn_search_APT(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
const Odr_oid *attributeSet, NMEM stream,
Z_SortKeySpecList *sort_sequence,
RSET *rset,
struct rset_key_control *kc)
{
+ RSET *rsets = nmem_malloc(stream, num_bases * sizeof(*rsets));
+ ZEBRA_RES res = ZEBRA_OK;
+ int i;
+ for (i = 0; i < num_bases; i++)
+ {
+
+ if (zebraExplain_curDatabase(zh->reg->zei, basenames[i]))
+ {
+ zebra_setError(zh, YAZ_BIB1_DATABASE_UNAVAILABLE,
+ basenames[i]);
+ res = ZEBRA_FAIL;
+ break;
+ }
+ res = rpn_search_database(zh, zapt, attributeSet, stream,
+ sort_sequence, 1, basenames+i,
+ rset_nmem, rsets+i, kc);
+ if (res != ZEBRA_OK)
+ break;
+ }
+ if (res != ZEBRA_OK)
+ { /* must clean up the already created sets */
+ int j;
+ for (i = 0; j < i; j++)
+ rset_delete(rsets[j]);
+ *rset = 0;
+ }
+ else
+ {
+ if (num_bases == 1)
+ *rset = rsets[0];
+ else if (num_bases == 0)
+ *rset = rset_create_null(rset_nmem, kc, 0);
+ else
+ *rset = rset_create_and(rset_nmem, kc, kc->scope,
+ num_bases, rsets);
+ }
+ return res;
+}
+
+static ZEBRA_RES rpn_search_database(ZebraHandle zh,
+ Z_AttributesPlusTerm *zapt,
+ const Odr_oid *attributeSet, NMEM stream,
+ Z_SortKeySpecList *sort_sequence,
+ int num_bases, char **basenames,
+ NMEM rset_nmem,
+ RSET *rset,
+ struct rset_key_control *kc)
+{
ZEBRA_RES res = ZEBRA_OK;
- unsigned reg_id;
+ const char *index_type;
char *search_type = NULL;
char rank_type[128];
int complete_flag;
log_level_rpn = yaz_log_module_level("rpn");
log_level_set = 1;
}
- zebra_maps_attr(zh->reg->zebra_maps, zapt, ®_id, &search_type,
+ zebra_maps_attr(zh->reg->zebra_maps, zapt, &index_type, &search_type,
rank_type, &complete_flag, &sort_flag);
- yaz_log(YLOG_DEBUG, "reg_id=%c", reg_id);
+ yaz_log(YLOG_DEBUG, "index_type=%s", index_type);
yaz_log(YLOG_DEBUG, "complete_flag=%d", complete_flag);
yaz_log(YLOG_DEBUG, "search_type=%s", search_type);
yaz_log(YLOG_DEBUG, "rank_type=%s", rank_type);
if (!strcmp(search_type, "phrase"))
{
res = rpn_search_APT_phrase(zh, zapt, termz, attributeSet, stream,
- reg_id, complete_flag, rank_type,
+ index_type, complete_flag, rank_type,
xpath_use,
num_bases, basenames, rset_nmem,
rset, kc);
else if (!strcmp(search_type, "and-list"))
{
res = rpn_search_APT_and_list(zh, zapt, termz, attributeSet, stream,
- reg_id, complete_flag, rank_type,
+ index_type, complete_flag, rank_type,
xpath_use,
num_bases, basenames, rset_nmem,
rset, kc);
else if (!strcmp(search_type, "or-list"))
{
res = rpn_search_APT_or_list(zh, zapt, termz, attributeSet, stream,
- reg_id, complete_flag, rank_type,
+ index_type, complete_flag, rank_type,
xpath_use,
num_bases, basenames, rset_nmem,
rset, kc);
else if (!strcmp(search_type, "numeric"))
{
res = rpn_search_APT_numeric(zh, zapt, termz, attributeSet, stream,
- reg_id, complete_flag, rank_type,
+ index_type, complete_flag, rank_type,
xpath_use,
num_bases, basenames, rset_nmem,
rset, kc);
-/* $Id: safari.c,v 1.9 2007-04-25 09:38:21 adam Exp $
+/* $Id: safari.c,v 1.10 2007-10-29 16:57:53 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
int nor = 0;
char field[40];
const char *cp = line;
+ char type_cstr[2];
#if 0
yaz_log(YLOG_LOG, "safari line: %s", line);
#endif
+ type_cstr[1] = '\0';
if (*cp >= '0' && *cp <= '9')
- recWord.index_type = '0'; /* the default is 0 (raw) */
+ type_cstr[0] = '0'; /* the default is 0 (raw) */
else
- recWord.index_type = *cp++; /* type given */
+ type_cstr[0] = *cp++; /* type given */
+ type_cstr[1] = '\0';
+ recWord.index_type = type_cstr;
if (tinfo->segments)
{
if (sscanf(cp, ZINT_FORMAT " " ZINT_FORMAT " " ZINT_FORMAT
-/* $Id: trunc.c,v 1.68 2007-01-15 15:10:17 adam Exp $
+/* $Id: trunc.c,v 1.69 2007-10-29 16:57:53 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
const char *term, int length, const char *flags,
int preserve_position, int term_type, NMEM rset_nmem,
struct rset_key_control *kctrl, int scope,
- struct ord_list *ol, int reg_type,
+ struct ord_list *ol, const char *index_type,
zint hits_limit, const char *term_ref_id)
{
TERMID termid;
int trunc_chunk;
termid = rset_term_create(term, length, flags, term_type, rset_nmem, ol,
- reg_type, hits_limit, term_ref_id);
+ *index_type, hits_limit, term_ref_id);
if (no < 1)
return rset_create_null(rset_nmem, kctrl, termid);
-/* $Id: zinfo.c,v 1.79 2007-10-29 11:10:43 adam Exp $
+/* $Id: zinfo.c,v 1.80 2007-10-29 16:57:53 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
#define ZINFO_DEBUG 0
struct zebSUInfo {
- int index_type;
+ char *index_type;
zinfo_index_category_t cat;
-#define ZEB_SU_SET_USE 1
-#define ZEB_SU_STR 2
- int which;
- union {
- char *str;
- } u;
+ char *str;
int ordinal;
zint doc_occurrences;
zint term_occurrences;
nmem_malloc(zei->nmem, sizeof(**zsuip));
if (node_type && node_type->u.data.len > 0)
- (*zsuip)->info.index_type = node_type->u.data.data[0];
+ (*zsuip)->info.index_type =
+ nmem_strdupn(zei->nmem,
+ node_type->u.data.data,
+ node_type->u.data.len);
else
{
yaz_log(YLOG_WARN, "Missing attribute 'type' in attribute info");
- (*zsuip)->info.index_type = 'w';
+ (*zsuip)->info.index_type = "w";
}
if (node_cat && node_cat->u.data.len > 0)
{
}
if (node_str)
{
- (*zsuip)->info.which = ZEB_SU_STR;
-
- (*zsuip)->info.u.str = nmem_strdupn(zei->nmem,
- node_str->u.data.data,
- node_str->u.data.len);
+ (*zsuip)->info.str = nmem_strdupn(zei->nmem,
+ node_str->u.data.data,
+ node_str->u.data.len);
}
else
{
for (zsui = zad->SUInfo; zsui; zsui = zsui->next)
{
data1_node *node_attr;
- char index_type_str[2];
-
node_attr = data1_mk_tag(zei->dh, zei->nmem, "attr", 0 /* attr */,
node_list);
- index_type_str[0] = zsui->info.index_type;
- index_type_str[1] = '\0';
data1_mk_tag_data_text(zei->dh, node_attr, "type",
- index_type_str, zei->nmem);
- if (zsui->info.which == ZEB_SU_STR)
- {
- data1_mk_tag_data_text(zei->dh, node_attr, "str",
- zsui->info.u.str, zei->nmem);
- }
+ zsui->info.index_type, zei->nmem);
+ data1_mk_tag_data_text(zei->dh, node_attr, "str",
+ zsui->info.str, zei->nmem);
data1_mk_tag_data_int(zei->dh, node_attr, "ordinal",
zsui->info.ordinal, zei->nmem);
int zebraExplain_lookup_attr_str(ZebraExplainInfo zei,
zinfo_index_category_t cat,
- int index_type,
+ const char *index_type,
const char *str)
{
struct zebSUInfoB **zsui;
assert(zei->curDatabaseInfo);
for (zsui = &zei->curDatabaseInfo->attributeDetails->SUInfo;
*zsui; zsui = &(*zsui)->next)
- if ( (index_type == -1 || (*zsui)->info.index_type == index_type)
+ if ( (index_type == 0
+ || !strcmp((*zsui)->info.index_type, index_type))
&& (*zsui)->info.cat == cat
- && (*zsui)->info.which == ZEB_SU_STR
- && !yaz_matchstr((*zsui)->info.u.str, str))
+ && !yaz_matchstr((*zsui)->info.str, str))
{
struct zebSUInfoB *zsui_this = *zsui;
}
int zebraExplain_lookup_ord(ZebraExplainInfo zei, int ord,
- int *index_type,
+ const char **index_type,
const char **db,
const char **string_index)
{
zsui = zebraExplain_get_sui_info(zei, ord, 0, db);
if (zsui)
{
- if (zsui->info.which == ZEB_SU_STR)
- if (string_index)
- *string_index = zsui->info.u.str;
+ if (string_index)
+ *string_index = zsui->info.str;
if (index_type)
*index_type = zsui->info.index_type;
return 0;
struct zebSUInfoB *zebraExplain_add_sui_info(ZebraExplainInfo zei,
zinfo_index_category_t cat,
- int index_type)
+ const char *index_type)
{
struct zebSUInfoB *zsui;
zei->curDatabaseInfo->attributeDetails->SUInfo = zsui;
zei->curDatabaseInfo->attributeDetails->dirty = 1;
zei->dirty = 1;
- zsui->info.index_type = index_type;
+ zsui->info.index_type = nmem_strdup(zei->nmem, index_type);
zsui->info.cat = cat;
zsui->info.doc_occurrences = 0;
zsui->info.term_occurrences = 0;
int zebraExplain_add_attr_str(ZebraExplainInfo zei,
zinfo_index_category_t cat,
- int index_type,
+ const char *index_type,
const char *index_name)
{
struct zebSUInfoB *zsui = zebraExplain_add_sui_info(zei, cat, index_type);
- zsui->info.which = ZEB_SU_STR;
- zsui->info.u.str = nmem_strdup(zei->nmem, index_name);
+ zsui->info.str = nmem_strdup(zei->nmem, index_name);
return zsui->info.ordinal;
}
-/* $Id: zinfo.h,v 1.39 2007-10-29 09:25:41 adam Exp $
+/* $Id: zinfo.h,v 1.40 2007-10-29 16:57:53 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
int zebraExplain_lookup_attr_str(ZebraExplainInfo zei,
zinfo_index_category_t cat,
- int index_type,
+ const char *index_type,
const char *str);
int zebraExplain_add_attr_str(ZebraExplainInfo zei,
zinfo_index_category_t cat,
- int index_type,
+ const char *index_type,
const char *str);
void zebraExplain_addSchema(ZebraExplainInfo zei, Odr_oid *oid);
void zebraExplain_recordCountIncrement(ZebraExplainInfo zei, int adjust_num);
void zebraExplain_flush(ZebraExplainInfo zei, void *updateHandle);
int zebraExplain_lookup_ord(ZebraExplainInfo zei, int ord,
- int *index_type, const char **db,
+ const char **index_type, const char **db,
const char **string_index);
int zebraExplain_ord_adjust_occurrences(ZebraExplainInfo zei, int ord,
-/* $Id: zsets.c,v 1.122 2007-08-21 11:06:47 adam Exp $
+/* $Id: zsets.c,v 1.123 2007-10-29 16:57:53 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
int relation;
int ord;
int numerical;
- int index_type;
+ const char *index_type;
};
void resultSetInsertSort(ZebraHandle zh, ZebraSet sset,
char this_entry_org[1024];
char other_entry_org[1024];
double diff;
- int index_type = criteria[j].index_type;
- zebra_term_untrans(zh, index_type, this_entry_org,
+ const char *index_type = criteria[j].index_type;
+ zebra_term_untrans(zh, *index_type, this_entry_org,
this_entry_buf);
- zebra_term_untrans(zh, index_type, other_entry_org,
+ zebra_term_untrans(zh, *index_type, other_entry_org,
other_entry_buf);
diff = atof(this_entry_org) - atof(other_entry_org);
sort_criteria[i].ord =
zebraExplain_lookup_attr_str(zh->reg->zei,
zinfo_index_category_sort,
- -1, sk->u.sortField);
+ 0, sk->u.sortField);
if (sks->which != Z_SortKeySpec_null
&& sort_criteria[i].ord == -1)
{
-/* $Id: zebramap.c,v 1.58 2007-03-21 13:47:12 adam Exp $
+/* $Id: zebramap.c,v 1.59 2007-10-29 16:57:54 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
}
int zebra_maps_attr(ZebraMaps zms, Z_AttributesPlusTerm *zapt,
- unsigned *reg_id, char **search_type, char *rank_type,
+ const char **index_type, char **search_type, char *rank_type,
int *complete_flag, int *sort_flag)
{
AttrType completeness;
*complete_flag = 1;
else
*complete_flag = 0;
- *reg_id = 0;
+ *index_type = 0;
*sort_flag =(sort_relation_value > 0) ? 1 : 0;
*search_type = "phrase";
sprintf(rank_type, "rank,w=%d,u=%d", weight_value, use_value);
}
if (*complete_flag)
- *reg_id = 'p';
+ *index_type = "p";
else
- *reg_id = 'w';
+ *index_type = "w";
switch (structure_value)
{
case 6: /* word list */
break;
case 107: /* local-number */
*search_type = "local";
- *reg_id = 0;
+ *index_type = 0;
break;
case 109: /* numeric string */
- *reg_id = 'n';
+ *index_type = "n";
*search_type = "numeric";
break;
case 104: /* urx */
- *reg_id = 'u';
+ *index_type = "u";
*search_type = "phrase";
break;
case 3: /* key */
- *reg_id = '0';
+ *index_type = "0";
*search_type = "phrase";
break;
case 4: /* year */
- *reg_id = 'y';
+ *index_type = "y";
*search_type = "phrase";
break;
case 5: /* date */
- *reg_id = 'd';
+ *index_type = "d";
*search_type = "phrase";
break;
case -2:
if (structure_str && *structure_str)
- *reg_id = *structure_str;
+ *index_type = structure_str;
else
return -1;
break;