From: Adam Dickmeiss Date: Fri, 22 Dec 2006 13:57:25 +0000 (+0000) Subject: Added support for specification of staticrank for grs-class of filters. X-Git-Tag: ZEBRA.2.0.8~14 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=b04a1cdb1a0345252a78caa8f7731089df314ad0;p=idzebra-moved-to-github.git Added support for specification of staticrank for grs-class of filters. This is enabled by using 'staticrank indexname' in .abs. Contents of indexname (elm ... indexname:w) is then used as value for staticrank. --- diff --git a/NEWS b/NEWS index 5f9face..a4a724e 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,7 @@ +Added support for specification of staticrank for grs-class of filters. +This is enabled by using 'staticrank indexname' in .abs. Contents of +indexname (elm ... indexname:w) is then used as value for staticrank. + Implemented sorting via the ISAMB system. To enable, use sortindex:i in zebra.cfg. diff --git a/data1/d1_absyn.c b/data1/d1_absyn.c index eac90f7..96f3b6b 100644 --- a/data1/d1_absyn.c +++ b/data1/d1_absyn.c @@ -1,4 +1,4 @@ -/* $Id: d1_absyn.c,v 1.31 2006-10-26 23:49:14 adam Exp $ +/* $Id: d1_absyn.c,v 1.32 2006-12-22 13:57:25 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -703,6 +703,7 @@ static data1_absyn *data1_read_absyn(data1_handle dh, const char *file, res->reference = VAL_NONE; res->tagset = 0; res->encoding = 0; + res->staticrank = 0; res->xpath_indexing = (f ? DATA1_XPATH_INDEXING_DISABLE : default_xpath); res->systags = 0; @@ -1182,6 +1183,18 @@ static data1_absyn *data1_read_absyn(data1_handle dh, const char *file, (*systagsp)->value = nmem_strdup(data1_nmem_get(dh), argv[2]); systagsp = &(*systagsp)->next; } + else if (!strcmp(cmd, "staticrank")) + { + if (argc != 2) + { + yaz_log(YLOG_WARN, "%s:%d: Bad # or args for staticrank", + file, lineno); + } + else + { + res->staticrank = nmem_strdup(data1_nmem_get(dh), argv[1]); + } + } else { yaz_log(YLOG_WARN, "%s:%d: Unknown directive '%s'", file, @@ -1202,6 +1215,12 @@ static data1_absyn *data1_read_absyn(data1_handle dh, const char *file, *systagsp = 0; return res; } + +YAZ_EXPORT const char *data1_absyn_get_staticrank(data1_absyn *absyn) +{ + return absyn ? absyn->staticrank : 0; +} + /* * Local variables: * c-basic-offset: 4 diff --git a/include/d1_absyn.h b/include/d1_absyn.h index ad6ce11..6945ac0 100644 --- a/include/d1_absyn.h +++ b/include/d1_absyn.h @@ -1,4 +1,4 @@ -/* $Id: d1_absyn.h,v 1.8 2006-09-29 10:02:46 adam Exp $ +/* $Id: d1_absyn.h,v 1.9 2006-12-22 13:57:26 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -61,6 +61,7 @@ struct data1_absyn struct data1_xpelement *xp_elements; /* pop */ struct data1_systag *systags; char *encoding; + char *staticrank; enum DATA1_XPATH_INDEXING xpath_indexing; }; diff --git a/include/idzebra/data1.h b/include/idzebra/data1.h index 81af828..cae7269 100644 --- a/include/idzebra/data1.h +++ b/include/idzebra/data1.h @@ -1,4 +1,4 @@ -/* $Id: data1.h,v 1.19 2006-10-26 23:49:14 adam Exp $ +/* $Id: data1.h,v 1.20 2006-12-22 13:57:26 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -581,6 +581,8 @@ YAZ_EXPORT void data1_concat_text(data1_handle dh, NMEM m, data1_node *n); YAZ_EXPORT void data1_absyn_destroy(data1_handle dh); +YAZ_EXPORT const char *data1_absyn_get_staticrank(data1_absyn *absyn); + YAZ_END_CDECL #endif diff --git a/index/recgrs.c b/index/recgrs.c index c8bebf9..46805ab 100644 --- a/index/recgrs.c +++ b/index/recgrs.c @@ -1,4 +1,4 @@ -/* $Id: recgrs.c,v 1.11 2006-11-30 11:03:57 adam Exp $ +/* $Id: recgrs.c,v 1.12 2006-12-22 13:57:27 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -525,6 +525,25 @@ static void mk_tag_path_full(char *tag_path_full, size_t max, data1_node *n) } +static void index_staticrank(struct recExtractCtrl *p, + RecWord *wrd, + data1_absyn *absyn) +{ + const char *staticrank_index = data1_absyn_get_staticrank(absyn); + + if (staticrank_index && !strcmp(wrd->index_name, staticrank_index)) + { + char valz[20]; + size_t len = wrd->term_len; + + if (len > sizeof(valz)-1) + len = sizeof(valz)-1; + memcpy(valz, wrd->term_buf, len); + valz[len] = '\0'; + p->staticrank = atozint(valz); + } +} + static void index_xpath(struct source_parser *sp, data1_node *n, struct recExtractCtrl *p, int level, RecWord *wrd, @@ -537,6 +556,7 @@ static void index_xpath(struct source_parser *sp, data1_node *n, int termlist_only = 1; data1_termlist *tl; int xpdone = 0; + if (!n->root->u.root.absyn || n->root->u.root.absyn->xpath_indexing == DATA1_XPATH_INDEXING_ENABLE) @@ -544,6 +564,7 @@ static void index_xpath(struct source_parser *sp, data1_node *n, termlist_only = 0; } + switch (n->which) { case DATA1N_data: @@ -584,7 +605,10 @@ static void index_xpath(struct source_parser *sp, data1_node *n, fputc ('\n', stdout); } else + { (*p->tokenAdd)(&wrd_tl); + index_staticrank(p, &wrd_tl, n->root->u.root.absyn); + } if (wrd_tl.seqno > max_seqno) max_seqno = wrd_tl.seqno; } @@ -700,6 +724,8 @@ static void index_xpath(struct source_parser *sp, data1_node *n, wrd->term_buf = xp->value; wrd->term_len = strlen(xp->value); (*p->tokenAdd)(wrd); + index_staticrank(p, wrd, + n->root->u.root.absyn); } } } @@ -767,6 +793,7 @@ static void index_termlist (struct source_parser *sp, data1_node *par, { wrd->index_type = *tlist->structure; wrd->index_name = tlist->index_name; + index_staticrank(p, wrd, n->root->u.root.absyn); (*p->tokenAdd)(wrd); } }