-/* $Id: zrpn.c,v 1.200 2005-06-14 20:28:54 adam Exp $
+/* $Id: zrpn.c,v 1.201 2005-06-22 19:42:38 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
char *term_dst, int xpath_use,
struct ord_list **ol);
+static ZEBRA_RES term_limits_APT(ZebraHandle zh,
+ Z_AttributesPlusTerm *zapt,
+ zint *hits_limit_value,
+ const char **term_ref_id_str)
+{
+ AttrType term_ref_id_attr;
+ AttrType hits_limit_attr;
+
+ attr_init(&hits_limit_attr, zapt, 9);
+ *hits_limit_value = attr_find(&hits_limit_attr, NULL);
+
+ attr_init(&term_ref_id_attr, zapt, 10);
+ attr_find_ex(&term_ref_id_attr, NULL, term_ref_id_str);
+
+ /* no limit given ? */
+ if (*hits_limit_value == -1)
+ if (*term_ref_id_str)
+ {
+ /* use global if term_ref is present */
+ *hits_limit_value = zh->approx_limit;
+ }
+ else
+ {
+ /* no counting if term_ref is not present */
+ *hits_limit_value = 0;
+ }
+ else if (*hits_limit_value == 0)
+ {
+ /* 0 is the same as global limit */
+ *hits_limit_value = zh->approx_limit;
+ }
+ yaz_log(YLOG_LOG, "term_limits_APT ref_id=%s limit=" ZINT_FORMAT,
+ *term_ref_id_str ? *term_ref_id_str : "none",
+ *hits_limit_value);
+ return ZEBRA_OK;
+}
+
static ZEBRA_RES term_trunc(ZebraHandle zh,
Z_AttributesPlusTerm *zapt,
const char **term_sub,
{
ZEBRA_RES res;
struct ord_list *ol;
+ zint hits_limit_value;
+ const char *term_ref_id_str = 0;
*rset = 0;
+
+ term_limits_APT(zh, zapt, &hits_limit_value, &term_ref_id_str);
grep_info->isam_p_indx = 0;
res = string_term(zh, zapt, term_sub, attributeSet, stream, grep_info,
reg_type, complete_flag, num_bases, basenames,
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);
+ kc, kc->scope, ol, reg_type, hits_limit_value,
+ term_ref_id_str);
if (!*rset)
return ZEBRA_FAIL;
return ZEBRA_OK;
return ZEBRA_OK;
}
+
static ZEBRA_RES rpn_search_APT_numeric(ZebraHandle zh,
Z_AttributesPlusTerm *zapt,
const char *termz,
ZEBRA_RES res;
struct grep_info grep_info;
int alloc_sets = 0;
+ zint hits_limit_value;
+ const char *term_ref_id_str = 0;
+
+ term_limits_APT(zh, zapt, &hits_limit_value, &term_ref_id_str);
yaz_log(log_level_rpn, "APT_numeric t='%s'", termz);
if (grep_info_prepare(zh, zapt, &grep_info, reg_type) == ZEBRA_FAIL)
strlen(term_dst), rank_type,
0 /* preserve position */,
zapt->term->which, rset_nmem,
- kc, kc->scope, 0, reg_type);
+ kc, kc->scope, 0, reg_type,
+ hits_limit_value,
+ term_ref_id_str);
if (!result_sets[num_result_sets])
break;
num_result_sets++;
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);
+ kc, kc->scope, 0, reg_type, 0 /* hits_limit */,
+ 0 /* term_ref_id_str */);
grep_info_delete(&grep_info);
return rset;
}
rset = rset_trunc(zh, &scan_info_array[j0].list[ptr[j0]].isam_p, 1,
glist[lo].term, strlen(glist[lo].term),
NULL, 0, zapt->term->which, rset_nmem,
- kc, kc->scope, 0, reg_id);
+ kc, kc->scope, 0, reg_id, 0 /* hits_limit */,
+ 0 /* term_ref_id_str */);
}
ptr[j0]++; /* move index for this set .. */
/* get result set for remaining scan terms */
glist[lo].term,
strlen(glist[lo].term), NULL, 0,
zapt->term->which,rset_nmem,
- kc, kc->scope, 0, reg_id);
+ kc, kc->scope, 0, reg_id, 0 /* hits_limit */,
+ 0 /* term_ref_id_str */ );
rset = rsmulti_or_create(rset_nmem, kc,
kc->scope, 0 /* termid */,
2, rsets);
(zh, &scan_info_array[j0].list[before-1-ptr[j0]].isam_p, 1,
glist[lo].term, strlen(glist[lo].term),
NULL, 0, zapt->term->which, rset_nmem,
- kc, kc->scope, 0, reg_id);
+ kc, kc->scope, 0, reg_id, 0 /* hits_limit */,
+ 0 /* term_ref_id_str */);
ptr[j0]++;
glist[lo].term,
strlen(glist[lo].term), NULL, 0,
zapt->term->which, rset_nmem,
- kc, kc->scope, 0, reg_id);
+ kc, kc->scope, 0, reg_id, 0 /* hits_limit */,
+ 0 /* term_ref_id_str */);
rset = rsmulti_or_create(rset_nmem, kc,
kc->scope, 0 /* termid */, 2, rsets);