-/* $Id: extract.c,v 1.222 2006-06-22 09:48:08 adam Exp $
+/* $Id: extract.c,v 1.226 2006-08-15 14:28:33 adam Exp $
Copyright (C) 1995-2006
Index Data ApS
for more details.
You should have received a copy of the GNU General Public License
-along with Zebra; see the file LICENSE.zebra. If not, write to the
-Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA.
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
*/
#include <stdio.h>
}
}
-static void extract_add_index_string (RecWord *p, const char *str, int length);
+static void extract_add_index_string (RecWord *p,
+ zinfo_index_category_t cat,
+ const char *str, int length);
static void extract_set_store_data_prepare(struct recExtractCtrl *p);
static void extract_init (struct recExtractCtrl *p, RecWord *w)
{
- w->zebra_maps = p->zebra_maps;
w->seqno = 1;
w->index_name = "any";
w->index_type = 'w';
{
int i;
int ch = -1;
+ zinfo_index_category_t cat = zinfo_index_category_index;
for (i = 0; i<ws_length; i++)
ws[i] = NULL;
if (ch < 0)
- ch = zebraExplain_lookup_attr_str(zh->reg->zei, '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, '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, 'w', index_name);
+ ch = zebraExplain_lookup_attr_str(zh->reg->zei, cat, 'w', index_name);
if (ch < 0)
return ;
else
ctrl->seqno[i] = 0;
}
- ctrl->zebra_maps = zh->reg->zebra_maps;
ctrl->flagShowRecords = !zh->m_flag_rw;
}
{
RecWord word;
extract_init(ctrl, &word);
- word.index_name = "allrecords";
+ word.index_name = "_ALLRECORDS";
word.index_type = 'w';
word.seqno = 1;
- extract_add_index_string (&word, "", 0);
+ extract_add_index_string (&word, zinfo_index_category_alwaysmatches,
+ "", 0);
}
static ZEBRA_RES file_extract_record(ZebraHandle zh,
}
}
-static void extract_add_index_string(RecWord *p, const char *str, int length)
+static void extract_add_index_string(RecWord *p, zinfo_index_category_t cat,
+ const char *str, int length)
{
struct it_key key;
-
ZebraHandle zh = p->extractCtrl->handle;
ZebraExplainInfo zei = zh->reg->zei;
int ch;
if (!p->index_name)
return;
- ch = zebraExplain_lookup_attr_str(zei, p->index_type, p->index_name);
+ ch = zebraExplain_lookup_attr_str(zei, cat, p->index_type, p->index_name);
if (ch < 0)
- ch = zebraExplain_add_attr_str(zei, p->index_type, p->index_name);
+ ch = zebraExplain_add_attr_str(zei, cat, p->index_type, p->index_name);
key.len = 4;
key.mem[0] = ch;
static void extract_add_sort_string(RecWord *p, const char *str, int length)
{
struct it_key key;
-
ZebraHandle zh = p->extractCtrl->handle;
ZebraExplainInfo zei = zh->reg->zei;
int ch;
+ zinfo_index_category_t cat = zinfo_index_category_sort;
+
if (!p->index_name)
return;
- ch = zebraExplain_lookup_attr_str(zei, p->index_type, p->index_name);
+ ch = zebraExplain_lookup_attr_str(zei, cat, p->index_type, p->index_name);
if (ch < 0)
- ch = zebraExplain_add_attr_str(zei, p->index_type, p->index_name);
+ ch = zebraExplain_add_attr_str(zei, cat, p->index_type, p->index_name);
key.len = 4;
key.mem[0] = ch;
key.mem[1] = p->record_id;
static void extract_add_string (RecWord *p, const char *string, int length)
{
+ ZebraHandle zh = p->extractCtrl->handle;
assert (length > 0);
- if (zebra_maps_is_sort (p->zebra_maps, p->index_type))
+ if (zebra_maps_is_sort (zh->reg->zebra_maps, p->index_type))
extract_add_sort_string (p, string, length);
else
{
- extract_add_index_string(p, string, length);
- if (zebra_maps_is_alwaysmatches(p->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))
{
RecWord word;
memcpy(&word, p, sizeof(word));
word.seqno = 1;
- extract_add_index_string (&word, "", 0);
+ extract_add_index_string(
+ &word, zinfo_index_category_alwaysmatches, "", 0);
}
}
}
static void extract_add_incomplete_field (RecWord *p)
{
+ ZebraHandle zh = p->extractCtrl->handle;
const char *b = p->term_buf;
int remain = p->term_len;
const char **map = 0;
if (remain > 0)
- map = zebra_maps_input(p->zebra_maps, p->index_type, &b, remain, 0);
+ map = zebra_maps_input(zh->reg->zebra_maps, p->index_type, &b, remain, 0);
while (map)
{
{
remain = p->term_len - (b - p->term_buf);
if (remain > 0)
- map = zebra_maps_input(p->zebra_maps, p->index_type, &b,
+ map = zebra_maps_input(zh->reg->zebra_maps, p->index_type, &b,
remain, 0);
else
map = 0;
buf[i++] = *(cp++);
remain = p->term_len - (b - p->term_buf);
if (remain > 0)
- map = zebra_maps_input(p->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;
}
static void extract_add_complete_field (RecWord *p)
{
+ ZebraHandle zh = p->extractCtrl->handle;
const char *b = p->term_buf;
char buf[IT_MAX_WORD+1];
const char **map = 0;
int i = 0, remain = p->term_len;
if (remain > 0)
- map = zebra_maps_input (p->zebra_maps, p->index_type, &b, remain, 1);
+ map = zebra_maps_input (zh->reg->zebra_maps, p->index_type, &b, remain, 1);
while (remain > 0 && i < IT_MAX_WORD)
{
if (remain > 0)
{
int first = i ? 0 : 1; /* first position */
- map = zebra_maps_input(p->zebra_maps, p->index_type, &b, remain, first);
+ map = zebra_maps_input(zh->reg->zebra_maps, p->index_type, &b, remain, first);
}
else
map = 0;
remain = p->term_len - (b - p->term_buf);
if (remain > 0)
{
- map = zebra_maps_input (p->zebra_maps, p->index_type, &b,
+ map = zebra_maps_input (zh->reg->zebra_maps, p->index_type, &b,
remain, 0);
}
else
static void extract_token_add(RecWord *p)
{
+ ZebraHandle zh = p->extractCtrl->handle;
WRBUF wrbuf;
if (log_level)
yaz_log(log_level, "extract_token_add "
"type=%c 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(p->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 (p->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);