From e1352999e1be86b0ce5c2698bb62f9fc7d598a4f Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 16 Jan 2007 15:31:23 +0000 Subject: [PATCH] For truncations being limited (abort at truncmax terms), zebrasrv returns SearchResponse with resultSetStatus=subset. --- NEWS | 7 +++++-- index/index.h | 8 +++++--- index/rpnsearch.c | 11 ++++++++--- index/zebraapi.c | 13 +++++++++++-- index/zsets.c | 12 +++++------- 5 files changed, 34 insertions(+), 17 deletions(-) diff --git a/NEWS b/NEWS index 90c6112..d1c489c 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,8 @@ -For estimated hit counts, Zebra returns resultSetStatus=estimtate as -part of SearchResponse. Requires YAZ 2.1.47 or later. +For truncations being limited (abort at truncmax terms), zebrasrv returns +SearchResponse with resultSetStatus=subset. + +For estimated hit counts, zebrasrv returns SearchResponse with +resultSetStatus=estimate. --- 2.0.8 2007/01/15 diff --git a/index/index.h b/index/index.h index f890e57..92a4e22 100644 --- a/index/index.h +++ b/index/index.h @@ -1,4 +1,4 @@ -/* $Id: index.h,v 1.191 2007-01-16 15:01:15 adam Exp $ +/* $Id: index.h,v 1.192 2007-01-16 15:31:23 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -199,6 +199,7 @@ struct zebra_session { char *dbaccesslist; int errCode; char *errString; + int partial_result; #if HAVE_SYS_TIMES_H struct tms tms1; struct tms tms2; @@ -286,8 +287,7 @@ ZebraSet resultSetGet(ZebraHandle zh, const char *name); ZEBRA_RES resultSetAddRPN(ZebraHandle zh, NMEM m, Z_RPNQuery *rpn, int num_bases, char **basenames, const char *setname, - zint *hits, int *estimated_hit_count, - int *partial_resultset); + zint *hits, int *estimated_hit_count); RSET resultSetRef(ZebraHandle zh, const char *resultSetId); void resultSetDestroy(ZebraHandle zh, int num_names, char **names, int *statuses); @@ -412,6 +412,8 @@ ZEBRA_RES zapt_term_to_utf8(ZebraHandle zh, Z_AttributesPlusTerm *zapt, char *termz); +void zebra_set_partial_result(ZebraHandle zh); + int zebra_check_res(Res res); #define FIRST_IN_FIELD_STR "\001^" diff --git a/index/rpnsearch.c b/index/rpnsearch.c index 7743362..f581512 100644 --- a/index/rpnsearch.c +++ b/index/rpnsearch.c @@ -1,4 +1,4 @@ -/* $Id: rpnsearch.c,v 1.6 2007-01-15 15:10:17 adam Exp $ +/* $Id: rpnsearch.c,v 1.7 2007-01-16 15:31:23 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -1183,7 +1183,9 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, grep_info, &max_pos, ord_len /* number of "exact" chars */, grep_handle); - if (r) + if (r == 1) + zebra_set_partial_result(zh); + else if (r) yaz_log(YLOG_WARN, "dict_lookup_grep fail %d", r); } if (!bases_ok) @@ -1699,7 +1701,10 @@ static int numeric_relation(ZebraHandle zh, Z_AttributesPlusTerm *zapt, yaz_log(log_level_rpn, "dict_lookup_grep: %s", term_tmp); r = dict_lookup_grep(zh->reg->dict, term_dict, 0, grep_info, max_pos, 0, grep_handle); - if (r != 0 && r != 1) + + if (r == 1) + zebra_set_partial_result(zh); + else if (r) yaz_log(YLOG_WARN, "dict_lookup_grep fail, rel = gt: %d", r); yaz_log(log_level_rpn, "%d positions", grep_info->isam_p_indx); return 1; diff --git a/index/zebraapi.c b/index/zebraapi.c index a8e8039..091fbf8 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -1,4 +1,4 @@ -/* $Id: zebraapi.c,v 1.243 2007-01-16 15:01:15 adam Exp $ +/* $Id: zebraapi.c,v 1.244 2007-01-16 15:31:23 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -1015,6 +1015,11 @@ ZEBRA_RES zebra_set_approx_limit(ZebraHandle zh, zint approx_limit) return ZEBRA_OK; } +void zebra_set_partial_result(ZebraHandle zh) +{ + zh->partial_result = 1; +} + ZEBRA_RES zebra_search_RPN_x(ZebraHandle zh, ODR o, Z_RPNQuery *query, const char *setname, zint *hits, int *estimated_hit_count, @@ -1030,12 +1035,16 @@ ZEBRA_RES zebra_search_RPN_x(ZebraHandle zh, ODR o, Z_RPNQuery *query, assert(setname); yaz_log(log_level, "zebra_search_rpn"); + zh->partial_result = 0; + if (zebra_begin_read(zh) == ZEBRA_FAIL) return ZEBRA_FAIL; r = resultSetAddRPN(zh, odr_extract_mem(o), query, zh->num_basenames, zh->basenames, setname, - hits, estimated_hit_count, partial_resultset); + hits, estimated_hit_count); + + *partial_resultset = zh->partial_result; zebra_end_read(zh); return r; } diff --git a/index/zsets.c b/index/zsets.c index 9b045d4..e424abe 100644 --- a/index/zsets.c +++ b/index/zsets.c @@ -1,4 +1,4 @@ -/* $Id: zsets.c,v 1.116 2007-01-16 15:01:15 adam Exp $ +/* $Id: zsets.c,v 1.117 2007-01-16 15:31:23 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -146,11 +146,10 @@ static ZEBRA_RES resultSetSearch(ZebraHandle zh, NMEM nmem, NMEM rset_nmem, } -ZEBRA_RES resultSetAddRPN (ZebraHandle zh, NMEM m, Z_RPNQuery *rpn, - int num_bases, char **basenames, - const char *setname, - zint *hits, int *estimated_hit_count, - int *partial_resultset) +ZEBRA_RES resultSetAddRPN(ZebraHandle zh, NMEM m, Z_RPNQuery *rpn, + int num_bases, char **basenames, + const char *setname, + zint *hits, int *estimated_hit_count) { ZebraSet zebraSet; int i; @@ -158,7 +157,6 @@ ZEBRA_RES resultSetAddRPN (ZebraHandle zh, NMEM m, Z_RPNQuery *rpn, *hits = 0; *estimated_hit_count = 0; - *partial_resultset = 0; zebraSet = resultSetAdd(zh, setname, 1); if (!zebraSet) -- 1.7.10.4