Changed type of index_type char/int to string.
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 29 Oct 2007 16:57:51 +0000 (16:57 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 29 Oct 2007 16:57:51 +0000 (16:57 +0000)
The index_type is part of the RecWord structure which is used by all
record filters. It used to be a int char (e.g. 'w'). It is now a string
so that arbitrary index types can be specified . For example there might
be a Greek Title (e.g. word:greek or word_greek).

21 files changed:
include/idzebra/recctrl.h
include/zebramap.h
index/alvis.c
index/attribute.c
index/extract.c
index/index.h
index/invstat.c
index/kinput.c
index/mod_dom.c
index/ranksimilarity.c
index/rankstatic.c
index/recgrs.c
index/retrieve.c
index/rpnscan.c
index/rpnsearch.c
index/safari.c
index/trunc.c
index/zinfo.c
index/zinfo.h
index/zsets.c
util/zebramap.c

index 92f46e4..207b32d 100644 (file)
@@ -1,4 +1,4 @@
-/* $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
 
@@ -50,7 +50,7 @@ YAZ_BEGIN_CDECL
 /** 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 */
index dc244ae..26329d3 100644 (file)
@@ -1,4 +1,4 @@
-/* $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
 
@@ -52,7 +52,7 @@ const char *zebra_maps_output(ZebraMaps, unsigned reg_id, const char **from);
 
 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
index 2a24a64..b3f533f 100644 (file)
@@ -1,4 +1,4 @@
-/* $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
 
@@ -72,16 +72,6 @@ struct filter_info {
 
 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)
 {
@@ -398,10 +388,10 @@ static void index_node(struct filter_info *tinfo,  struct recExtractCtrl *ctrl,
            }
            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);
 
index fc78955..305ab8c 100644 (file)
@@ -1,4 +1,4 @@
-/* $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
 
@@ -69,7 +69,7 @@ static int att_getentbyatt(ZebraHandle zi, const Odr_oid *set, int att,
 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)
 {
@@ -134,7 +134,7 @@ ZEBRA_RES zebra_attr_list_get_ord(ZebraHandle zh,
 
 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)
@@ -172,14 +172,14 @@ ZEBRA_RES zebra_apt_get_ord(ZebraHandle zh,
                                             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);
             
         }
@@ -205,7 +205,7 @@ ZEBRA_RES zebra_sort_get_ord(ZebraHandle zh,
     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;
 }
index 0eec47e..f0ea3ab 100644 (file)
@@ -1,4 +1,4 @@
-/* $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
 
@@ -122,7 +122,7 @@ static void extract_init(struct recExtractCtrl *p, RecWord *w)
 {
     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;
@@ -148,7 +148,7 @@ static void snippet_add_complete_field(RecWord *p, int ord)
     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)
     {
@@ -162,7 +162,7 @@ static void snippet_add_complete_field(RecWord *p, int ord)
            {
                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
@@ -192,7 +192,7 @@ static void snippet_add_complete_field(RecWord *p, int ord)
            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
@@ -218,7 +218,7 @@ static void snippet_add_incomplete_field(RecWord *p, int ord)
     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)
     {
@@ -231,7 +231,7 @@ static void snippet_add_incomplete_field(RecWord *p, int ord)
            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;
@@ -256,7 +256,7 @@ static void snippet_add_incomplete_field(RecWord *p, int ord)
            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;
        }
@@ -266,7 +266,7 @@ static void snippet_add_incomplete_field(RecWord *p, int ord)
         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++;
@@ -286,13 +286,13 @@ static void snippet_token_add(RecWord *p)
     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);
@@ -351,11 +351,11 @@ static void searchRecordKey(ZebraHandle zh,
         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 ;
@@ -540,7 +540,7 @@ static void all_matches_add(struct recExtractCtrl *ctrl)
     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);
@@ -1272,13 +1272,14 @@ void extract_rec_keys_log(ZebraHandle zh, int is_insert,
             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++)
@@ -1306,12 +1307,12 @@ void extract_rec_keys_log(ZebraHandle zh, int is_insert,
                 {
                     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);
@@ -1502,7 +1503,7 @@ ZEBRA_RES zebra_rec_keys_to_snippets(ZebraHandle zh,
            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];
@@ -1511,7 +1512,7 @@ ZEBRA_RES zebra_rec_keys_to_snippets(ZebraHandle zh,
            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);
@@ -1533,7 +1534,7 @@ void print_rec_keys(ZebraHandle zh, zebra_rec_keys_t reckeys)
        {
            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);
@@ -1542,7 +1543,7 @@ void print_rec_keys(ZebraHandle zh, zebra_rec_keys_t reckeys)
            
            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); 
@@ -1615,11 +1616,11 @@ static void extract_add_string(RecWord *p, const char *string, int length)
     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));
@@ -1629,11 +1630,11 @@ static void extract_add_string(RecWord *p, const char *string, int length)
                 &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);
     }
@@ -1648,7 +1649,7 @@ static void extract_add_incomplete_field(RecWord *p)
     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)
     {
@@ -1660,7 +1661,7 @@ static void extract_add_incomplete_field(RecWord *p)
        {
            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;
@@ -1676,7 +1677,7 @@ static void extract_add_incomplete_field(RecWord *p)
                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;
        }
@@ -1686,7 +1687,7 @@ static void extract_add_incomplete_field(RecWord *p)
         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);
@@ -1707,7 +1708,7 @@ static void extract_add_complete_field(RecWord *p)
     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)
     {
@@ -1718,7 +1719,7 @@ static void extract_add_complete_field(RecWord *p)
            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;
@@ -1746,7 +1747,7 @@ static void extract_add_complete_field(RecWord *p)
            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
@@ -1792,12 +1793,8 @@ static void extract_token_add2_index(ZebraHandle zh, zebra_index_type_t type,
 
 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))
@@ -1835,17 +1832,17 @@ static void extract_token_add(RecWord *p)
     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);
index b9d8432..7a5152c 100644 (file)
@@ -1,4 +1,4 @@
-/* $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
 
@@ -281,7 +281,7 @@ RSET rset_trunc(ZebraHandle zh, ISAM_P *isam_p, int no,
                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,
@@ -386,7 +386,7 @@ void zebra_term_untrans(ZebraHandle zh, 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);
@@ -394,7 +394,7 @@ ZEBRA_RES zebra_apt_get_ord(ZebraHandle zh,
 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);
 
index 5876bed..3ec3a32 100644 (file)
@@ -1,4 +1,4 @@
-/* $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
 
@@ -51,7 +51,7 @@ static void print_dict_item (ZebraHandle zh, const char *s, zint count,
     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)
@@ -60,7 +60,7 @@ static void print_dict_item (ZebraHandle zh, const char *s, zint count,
     {
         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);
index 57dab07..cd86e32 100644 (file)
@@ -1,4 +1,4 @@
-/* $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
 
@@ -378,7 +378,7 @@ void zebra_log_dict_entry(ZebraHandle zh, const char *s)
     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);
@@ -389,9 +389,9 @@ void zebra_log_dict_entry(ZebraHandle zh, const char *s)
         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);
     }
 }
index 4d8b02d..f369c68 100644 (file)
@@ -1,4 +1,4 @@
-/* $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
 
@@ -780,7 +780,7 @@ static void index_value_of(struct filter_info *tinfo,
 
                 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)
@@ -790,10 +790,6 @@ static void index_value_of(struct filter_info *tinfo,
                             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 */
index e9a572c..68ee9f8 100644 (file)
@@ -1,4 +1,4 @@
-/* $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
 
@@ -225,7 +225,7 @@ static void *begin (struct zebra_register *reg,
           
          for (; ol; ol = ol->next)
             {
-              int index_type = 0;
+              const char *index_type = 0;
               const char *db = 0;
               const char *string_index = 0;
 
@@ -239,13 +239,13 @@ static void *begin (struct zebra_register *reg,
                   += 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;
index 144d60c..c6fec9b 100644 (file)
@@ -1,4 +1,4 @@
-/* $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
 
@@ -91,7 +91,7 @@ static void *begin (struct zebra_register *reg,
 
        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;
@@ -101,11 +101,11 @@ static void *begin (struct zebra_register *reg,
                                    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)++;
index 10abf8c..3db3fc9 100644 (file)
@@ -1,4 +1,4 @@
-/* $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
 
@@ -481,20 +481,20 @@ static void index_xpath_attr(char *tag_path, char *name, char *value,
                              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);
@@ -563,7 +563,7 @@ static void index_xpath(struct source_parser *sp, data1_node *n,
            {
                /* 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);
@@ -600,14 +600,14 @@ static void index_xpath(struct source_parser *sp, data1_node *n,
        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;
@@ -646,7 +646,7 @@ static void index_xpath(struct source_parser *sp, data1_node *n,
                     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);
@@ -664,7 +664,7 @@ static void index_xpath(struct source_parser *sp, data1_node *n,
                             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--;
@@ -700,7 +700,7 @@ static void index_xpath(struct source_parser *sp, data1_node *n,
                                 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);
@@ -769,7 +769,7 @@ static void index_termlist(struct source_parser *sp, data1_node *par,
            }
            else
            {
-               wrd->index_type = *tlist->structure;
+               wrd->index_type = tlist->structure;
                wrd->index_name = tlist->index_name;
                (*p->tokenAdd)(wrd);
            }
index ebea719..cd87235 100644 (file)
@@ -1,4 +1,4 @@
-/* $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
 
@@ -131,6 +131,7 @@ int zebra_special_sort_fetch(ZebraHandle zh, zint sysno, ODR odr,
     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 */
@@ -161,9 +162,12 @@ int zebra_special_sort_fetch(ZebraHandle zh, zint sysno, ODR odr,
     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 */
@@ -171,7 +175,7 @@ int zebra_special_sort_fetch(ZebraHandle zh, zint sysno, ODR odr,
     {
         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();
@@ -182,8 +186,7 @@ int zebra_special_sort_fetch(ZebraHandle zh, zint sysno, ODR odr,
 
         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))
         {
@@ -195,7 +198,7 @@ int zebra_special_sort_fetch(ZebraHandle zh, zint sysno, ODR odr,
 
             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");
@@ -204,7 +207,7 @@ int zebra_special_sort_fetch(ZebraHandle zh, zint sysno, ODR odr,
         {
             *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);
@@ -228,6 +231,7 @@ int zebra_special_index_fetch(ZebraHandle zh, zint sysno, ODR odr,
     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; */
@@ -247,11 +251,12 @@ int zebra_special_index_fetch(ZebraHandle zh, zint sysno, ODR odr,
                      &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];
@@ -263,8 +268,8 @@ int zebra_special_index_fetch(ZebraHandle zh, zint sysno, ODR odr,
             
             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_;
         }
@@ -300,7 +305,7 @@ int zebra_special_index_fetch(ZebraHandle zh, zint sysno, ODR odr,
         {
             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;
@@ -319,10 +324,9 @@ int zebra_special_index_fetch(ZebraHandle zh, zint sysno, ODR odr,
             {
                 /* 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))
@@ -330,7 +334,7 @@ int zebra_special_index_fetch(ZebraHandle zh, zint sysno, ODR odr,
                             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]);
@@ -342,7 +346,7 @@ int zebra_special_index_fetch(ZebraHandle zh, zint sysno, ODR odr,
                         {
                             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, 
@@ -411,7 +415,7 @@ static void snippet_xml_record(ZebraHandle zh, WRBUF wrbuf, zebra_snippets *doc)
     {
         if (doc_w->mark)
         {
-            int index_type;
+            const char *index_type;
             const char *db = 0;
             const char *string_index = 0;
 
@@ -421,7 +425,7 @@ static void snippet_xml_record(ZebraHandle zh, WRBUF wrbuf, zebra_snippets *doc)
             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>");
index 5fd6b38..839d88e 100644 (file)
@@ -1,4 +1,4 @@
-/* $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
 
@@ -45,7 +45,7 @@ int log_scan = YLOG_LOG;
 
 /* 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];
 
@@ -63,7 +63,8 @@ static ZEBRA_RES trans_scan_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
             
         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
@@ -181,7 +182,7 @@ static int scan_save_set(ZebraHandle zh, ODR stream, NMEM nmem,
                          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)
 {
@@ -257,7 +258,7 @@ static int scan_save_set(ZebraHandle zh, ODR stream, NMEM nmem,
                 }
             }
             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);
@@ -278,7 +279,8 @@ static ZEBRA_RES rpn_scan_ver2(ZebraHandle zh, ODR stream, NMEM nmem,
                                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;
@@ -297,7 +299,7 @@ static ZEBRA_RES rpn_scan_ver2(ZebraHandle zh, ODR stream, NMEM nmem,
         *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();
@@ -467,7 +469,7 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
     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;
index 88a411f..094830f 100644 (file)
@@ -1,4 +1,4 @@
-/* $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
 
@@ -234,7 +234,7 @@ static void add_non_space(const char *start, const char *end,
 }
 
 /* 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)
 {
@@ -246,14 +246,14 @@ static int term_100(ZebraMaps zebra_maps, int reg_type,
     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)
         {
@@ -294,7 +294,7 @@ static int term_100(ZebraMaps zebra_maps, int reg_type,
 }
 
 /* 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)
 {
@@ -303,7 +303,7 @@ static int term_101(ZebraMaps zebra_maps, int reg_type,
     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)
@@ -318,7 +318,7 @@ static int term_101(ZebraMaps zebra_maps, int reg_type,
         {
            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;
@@ -334,7 +334,8 @@ static int term_101(ZebraMaps zebra_maps, int reg_type,
 }
 
 /* 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)
 {
@@ -343,7 +344,7 @@ static int term_103(ZebraMaps zebra_maps, int reg_type, const char **src,
     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] &&
@@ -367,7 +368,7 @@ static int term_103(ZebraMaps zebra_maps, int reg_type, const char **src,
         {
            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;
@@ -384,16 +385,17 @@ static int term_103(ZebraMaps zebra_maps, int reg_type, const char **src,
 }
 
 /* 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)
 {
@@ -402,7 +404,7 @@ static int term_104(ZebraMaps zebra_maps, int reg_type,
     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)
@@ -447,7 +449,7 @@ static int term_104(ZebraMaps zebra_maps, int reg_type,
         {
            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;
@@ -463,7 +465,7 @@ static int term_104(ZebraMaps zebra_maps, int reg_type,
 }
 
 /* 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)
 {
@@ -472,7 +474,7 @@ static int term_105(ZebraMaps zebra_maps, int reg_type,
     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)
@@ -493,7 +495,7 @@ static int term_105(ZebraMaps zebra_maps, int reg_type,
         {
            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;
@@ -650,7 +652,7 @@ void string_rel_add_char(WRBUF term_p, WRBUF wsrc, int *indx)
 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;
@@ -666,7 +668,7 @@ static int string_relation(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
     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))
         {
@@ -702,7 +704,7 @@ static int string_relation(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
         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))
         {
@@ -739,7 +741,7 @@ static int string_relation(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
         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);
@@ -773,7 +775,7 @@ static int string_relation(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
         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);
@@ -815,7 +817,7 @@ static int string_relation(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
         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);
@@ -845,7 +847,7 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
                              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,
@@ -903,7 +905,7 @@ static ZEBRA_RES term_trunc(ZebraHandle zh,
                            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, 
@@ -923,7 +925,7 @@ static ZEBRA_RES term_trunc(ZebraHandle zh,
     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)
@@ -935,7 +937,7 @@ static ZEBRA_RES term_trunc(ZebraHandle zh,
                       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;
@@ -947,7 +949,7 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
                              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,
@@ -964,7 +966,7 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
 
     *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);
@@ -988,7 +990,7 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
             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;
 
@@ -1017,7 +1019,7 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
         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)
@@ -1031,7 +1033,7 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
            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;
@@ -1041,7 +1043,7 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
             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;
@@ -1051,7 +1053,7 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
             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;
@@ -1061,7 +1063,7 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
             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;
@@ -1071,7 +1073,7 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
             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;
@@ -1082,7 +1084,7 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
         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, &regex_range,
                          space_split, term_dst))
            {
@@ -1093,7 +1095,7 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
            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;
@@ -1103,7 +1105,7 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
             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;
@@ -1113,7 +1115,7 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
             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;
@@ -1246,7 +1248,7 @@ static ZEBRA_RES term_list_trunc(ZebraHandle zh,
                                 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, 
@@ -1261,7 +1263,7 @@ static ZEBRA_RES term_list_trunc(ZebraHandle zh,
 
     *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)
     { 
@@ -1279,7 +1281,7 @@ static ZEBRA_RES term_list_trunc(ZebraHandle zh,
        }
         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,
@@ -1307,7 +1309,7 @@ static ZEBRA_RES term_list_trunc(ZebraHandle zh,
 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,
@@ -1335,7 +1337,7 @@ static ZEBRA_RES rpn_search_APT_position(ZebraHandle zh,
         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);
@@ -1365,7 +1367,7 @@ static ZEBRA_RES rpn_search_APT_position(ZebraHandle zh,
             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;
 
@@ -1400,7 +1402,7 @@ static ZEBRA_RES rpn_search_APT_phrase(ZebraHandle zh,
                                       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, 
@@ -1412,7 +1414,7 @@ static ZEBRA_RES rpn_search_APT_phrase(ZebraHandle zh,
     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,
@@ -1425,7 +1427,7 @@ static ZEBRA_RES rpn_search_APT_phrase(ZebraHandle zh,
     {
         RSET first_set = 0;
         res = rpn_search_APT_position(zh, zapt, attributeSet, 
-                                      reg_type,
+                                      index_type,
                                       num_bases, basenames,
                                       rset_nmem, &first_set,
                                       kc);
@@ -1460,7 +1462,8 @@ static ZEBRA_RES rpn_search_APT_or_list(ZebraHandle zh,
                                        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,
@@ -1473,7 +1476,7 @@ static ZEBRA_RES rpn_search_APT_or_list(ZebraHandle zh,
     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,
@@ -1485,7 +1488,7 @@ static ZEBRA_RES rpn_search_APT_or_list(ZebraHandle zh,
     {
         RSET first_set = 0;
         res = rpn_search_APT_position(zh, zapt, attributeSet, 
-                                      reg_type,
+                                      index_type,
                                       num_bases, basenames,
                                       rset_nmem, &first_set,
                                       kc);
@@ -1527,7 +1530,8 @@ static ZEBRA_RES rpn_search_APT_and_list(ZebraHandle zh,
                                         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,
@@ -1540,7 +1544,7 @@ static ZEBRA_RES rpn_search_APT_and_list(ZebraHandle zh,
     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,
@@ -1552,7 +1556,7 @@ static ZEBRA_RES rpn_search_APT_and_list(ZebraHandle zh,
     {
         RSET first_set = 0;
         res = rpn_search_APT_position(zh, zapt, attributeSet, 
-                                      reg_type,
+                                      index_type,
                                       num_bases, basenames,
                                       rset_nmem, &first_set,
                                       kc);
@@ -1597,7 +1601,7 @@ static int numeric_relation(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
                            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)
 {
@@ -1617,7 +1621,7 @@ static int numeric_relation(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
     {
     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);
@@ -1628,7 +1632,7 @@ static int numeric_relation(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
         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);
@@ -1639,7 +1643,7 @@ static int numeric_relation(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
         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);
@@ -1650,7 +1654,7 @@ static int numeric_relation(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
         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);
@@ -1662,7 +1666,7 @@ static int numeric_relation(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
     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);
@@ -1698,7 +1702,7 @@ static ZEBRA_RES numeric_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
                               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,
@@ -1712,7 +1716,7 @@ static ZEBRA_RES numeric_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
 
     *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++)
     {
@@ -1730,7 +1734,7 @@ static ZEBRA_RES numeric_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
             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++;
@@ -1750,7 +1754,7 @@ static ZEBRA_RES numeric_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
         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)
@@ -1775,7 +1779,8 @@ static ZEBRA_RES rpn_search_APT_numeric(ZebraHandle zh,
                                        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,
@@ -1796,7 +1801,7 @@ static ZEBRA_RES rpn_search_APT_numeric(ZebraHandle zh,
     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)
     { 
@@ -1816,7 +1821,7 @@ static ZEBRA_RES rpn_search_APT_numeric(ZebraHandle zh,
         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)
@@ -1828,7 +1833,7 @@ static ZEBRA_RES rpn_search_APT_numeric(ZebraHandle zh,
                       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])
@@ -1985,7 +1990,7 @@ static int rpn_check_xpath(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
                
 
 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)
@@ -1993,7 +1998,7 @@ static RSET xpath_trunc(ZebraHandle zh, NMEM stream,
     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);
     
@@ -2026,7 +2031,7 @@ static RSET xpath_trunc(ZebraHandle zh, NMEM stream,
         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);
@@ -2142,7 +2147,8 @@ ZEBRA_RES rpn_search_xpath(ZebraHandle zh,
                     }
                 }
                 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);
             } 
@@ -2158,7 +2164,7 @@ ZEBRA_RES rpn_search_xpath(ZebraHandle zh,
                     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);
@@ -2166,7 +2172,7 @@ ZEBRA_RES rpn_search_xpath(ZebraHandle zh,
                     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);
@@ -2186,6 +2192,15 @@ ZEBRA_RES rpn_search_xpath(ZebraHandle zh,
 
 #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,
@@ -2194,8 +2209,56 @@ static ZEBRA_RES rpn_search_APT(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
                                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;
@@ -2210,10 +2273,10 @@ static ZEBRA_RES rpn_search_APT(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
         log_level_rpn = yaz_log_module_level("rpn");
         log_level_set = 1;
     }
-    zebra_maps_attr(zh->reg->zebra_maps, zapt, &reg_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);
@@ -2263,7 +2326,7 @@ static ZEBRA_RES rpn_search_APT(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
     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);
@@ -2271,7 +2334,7 @@ static ZEBRA_RES rpn_search_APT(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
     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);
@@ -2279,7 +2342,7 @@ static ZEBRA_RES rpn_search_APT(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
     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);
@@ -2292,7 +2355,7 @@ static ZEBRA_RES rpn_search_APT(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
     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);
index c4398dc..7ad9a5e 100644 (file)
@@ -1,4 +1,4 @@
-/* $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
 
@@ -135,14 +135,18 @@ static int filter_extract(void *clientData, struct recExtractCtrl *p)
        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 
index 96dafb2..c664daa 100644 (file)
@@ -1,4 +1,4 @@
-/* $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
 
@@ -404,7 +404,7 @@ RSET rset_trunc(ZebraHandle zi, ISAM_P *isam_p, int no,
                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;
@@ -412,7 +412,7 @@ RSET rset_trunc(ZebraHandle zi, ISAM_P *isam_p, int no,
     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);
     
index 551e2c2..d086ff2 100644 (file)
@@ -1,4 +1,4 @@
-/* $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
 
@@ -32,14 +32,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #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;
@@ -642,11 +637,14 @@ static void zebraExplain_readAttributeDetails(ZebraExplainInfo zei,
            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)
         {
@@ -688,11 +686,9 @@ static void zebraExplain_readAttributeDetails(ZebraExplainInfo zei,
         }
        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
        {
@@ -1087,20 +1083,13 @@ static void zebraExplain_writeAttributeDetails(ZebraExplainInfo zei,
     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);
 
@@ -1364,7 +1353,7 @@ static void zebraExplain_writeTarget(ZebraExplainInfo zei, int key_flush)
 
 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;
@@ -1372,10 +1361,10 @@ int zebraExplain_lookup_attr_str(ZebraExplainInfo zei,
     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;
 
@@ -1483,7 +1472,7 @@ zint zebraExplain_ord_get_term_occurrences(ZebraExplainInfo zei, int ord)
 }
 
 int zebraExplain_lookup_ord(ZebraExplainInfo zei, int ord,
-                           int *index_type, 
+                           const char **index_type, 
                            const char **db,
                            const char **string_index)
 {
@@ -1497,9 +1486,8 @@ int zebraExplain_lookup_ord(ZebraExplainInfo zei, int ord,
     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;
@@ -1532,7 +1520,7 @@ zebAccessObject zebraExplain_announceOid(ZebraExplainInfo zei,
 
 struct zebSUInfoB *zebraExplain_add_sui_info(ZebraExplainInfo zei,
                                              zinfo_index_category_t cat,
-                                             int index_type)
+                                             const char *index_type)
 {
     struct zebSUInfoB *zsui;
 
@@ -1542,7 +1530,7 @@ struct zebSUInfoB *zebraExplain_add_sui_info(ZebraExplainInfo zei,
     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;
@@ -1552,13 +1540,12 @@ struct zebSUInfoB *zebraExplain_add_sui_info(ZebraExplainInfo zei,
 
 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;
 }
 
index fd46688..6db107c 100644 (file)
@@ -1,4 +1,4 @@
-/* $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
 
@@ -73,11 +73,11 @@ int zebraExplain_add_attr_su(ZebraExplainInfo zei, int index_type,
     
 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);
@@ -87,7 +87,7 @@ void zebraExplain_loadAttsets(data1_handle dh, Res res);
 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,
index cdfc2d2..04cc69e 100644 (file)
@@ -1,4 +1,4 @@
-/* $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
 
@@ -542,7 +542,7 @@ struct sortKeyInfo {
     int relation;
     int ord;
     int numerical;
-    int index_type;
+    const char *index_type;
 };
 
 void resultSetInsertSort(ZebraHandle zh, ZebraSet sset,
@@ -579,10 +579,10 @@ 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);
                 
@@ -885,7 +885,7 @@ ZEBRA_RES resultSetSortSingle(ZebraHandle zh, NMEM nmem,
             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)
             {
index 0a7cfb9..170ccc0 100644 (file)
@@ -1,4 +1,4 @@
-/* $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
 
@@ -427,7 +427,7 @@ int zebra_maps_sort(ZebraMaps zms, Z_SortAttributes *sortAttributes,
 }
 
 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;
@@ -462,7 +462,7 @@ int zebra_maps_attr(ZebraMaps zms, Z_AttributesPlusTerm *zapt,
        *complete_flag = 1;
     else
        *complete_flag = 0;
-    *reg_id = 0;
+    *index_type = 0;
 
     *sort_flag =(sort_relation_value > 0) ? 1 : 0;
     *search_type = "phrase";
@@ -474,9 +474,9 @@ int zebra_maps_attr(ZebraMaps zms, Z_AttributesPlusTerm *zapt,
         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 */
@@ -496,31 +496,31 @@ int zebra_maps_attr(ZebraMaps zms, Z_AttributesPlusTerm *zapt,
        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;