From: Adam Dickmeiss Date: Tue, 16 Jan 2007 14:12:37 +0000 (+0000) Subject: Extended the GFS search facility. New member of bend_search_rr X-Git-Tag: YAZ.2.1.48~14 X-Git-Url: http://sru.miketaylor.org.uk/?a=commitdiff_plain;h=9e3111eaac05558be44beadb89eb7ba8c73eb9d5;p=yaz-moved-to-github.git Extended the GFS search facility. New member of bend_search_rr 'estimated_hit_count' signals that hits is known to be an estmate (higher or lower than real hit count). New member 'partial_resultset' signals that the search was partial (hit count is lower or equal than real hit count). For Z39.50, the information is stored in resultSetStatus member of SearchResponse APDU. For SRU, the information is signalled via SRU diagnostic 59: "Result set created with valid partial results available". --- diff --git a/NEWS b/NEWS index 23b6c52..88c13fb 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,12 @@ +Extended the GFS search facility. New member of bend_search_rr +'estimated_hit_count' signals that hits is known to be an estmate +(higher or lower than real hit count). New member 'partial_resultset' +signals that the search was partial (hit count is lower or equal than +real hit count). For Z39.50, the information is stored in resultSetStatus +member of SearchResponse APDU. For SRU, the information is signalled +via SRU diagnostic 59: "Result set created with valid partial results +available". + --- 2.1.46 2007/01/13 Implemented bug #806: Deal with HTTP clients sending LF in HTTP headers. diff --git a/client/client.c b/client/client.c index 91883c1..d7a1bcc 100644 --- a/client/client.c +++ b/client/client.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: client.c,v 1.322 2007-01-03 08:42:13 adam Exp $ + * $Id: client.c,v 1.323 2007-01-16 14:12:37 adam Exp $ */ /** \file client.c * \brief yaz-client program @@ -1633,7 +1633,25 @@ static int process_searchResponse(Z_SearchResponse *res) last_hit_count = *res->resultCount; if (setnumber >= 0) printf (", setno %d", setnumber); - printf ("\n"); + putchar('\n'); + if (res->resultSetStatus) + { + printf("Result Set Status: "); + switch(*res->resultSetStatus) + { + case Z_SearchResponse_subset: + printf("subset"); break; + case Z_SearchResponse_interim: + printf("interim"); break; + case Z_SearchResponse_none: + printf("none"); break; + case Z_SearchResponse_estimate: + printf("estimate"); break; + default: + printf("%d", *res->resultSetStatus); + } + putchar('\n'); + } display_searchResult (res->additionalSearchInfo); printf("records returned: %d\n", *res->numberOfRecordsReturned); diff --git a/include/yaz/backend.h b/include/yaz/backend.h index 6c6d806..7d1d2c6 100644 --- a/include/yaz/backend.h +++ b/include/yaz/backend.h @@ -24,7 +24,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* $Id: backend.h,v 1.41 2007-01-03 08:42:14 adam Exp $ */ +/* $Id: backend.h,v 1.42 2007-01-16 14:12:37 adam Exp $ */ /** * \file backend.h @@ -68,6 +68,8 @@ typedef struct { char *srw_sortKeys; /* holds SRU/SRW sortKeys info */ char *srw_setname; /* holds SRU/SRW generated resultsetID */ int *srw_setnameIdleTime; /* holds SRU/SRW life-time */ + int estimated_hit_count; /* if hit count is estimated */ + int partial_resultset; /* if result set is partial */ } bend_search_rr; /* extended present handler. Does not replace bend_fetch. */ diff --git a/src/seshigh.c b/src/seshigh.c index 5394cc4..ec28830 100644 --- a/src/seshigh.c +++ b/src/seshigh.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: seshigh.c,v 1.108 2007-01-03 08:42:15 adam Exp $ + * $Id: seshigh.c,v 1.109 2007-01-16 14:12:38 adam Exp $ */ /** * \file seshigh.c @@ -884,6 +884,8 @@ static void srw_bend_search(association *assoc, request *req, rr.srw_sortKeys = 0; rr.srw_setname = 0; rr.srw_setnameIdleTime = 0; + rr.estimated_hit_count = 0; + rr.partial_resultset = 0; rr.query = (Z_Query *) odr_malloc (assoc->decode, sizeof(*rr.query)); rr.query->u.type_1 = 0; @@ -1105,6 +1107,15 @@ static void srw_bend_search(association *assoc, request *req, srw_res->records = 0; } } + if (rr.estimated_hit_count || rr.partial_resultset) + { + yaz_add_srw_diagnostic( + assoc->encode, + &srw_res->diagnostics, + &srw_res->num_diagnostics, + YAZ_SRW_RESULT_SET_CREATED_WITH_VALID_PARTIAL_RESULTS_AVAILABLE, + 0); + } } } } @@ -2351,7 +2362,7 @@ static Z_APDU *process_initRequest(association *assoc, request *reqb) assoc->init->implementation_name, odr_prepend(assoc->encode, "GFS", resp->implementationName)); - version = odr_strdup(assoc->encode, "$Revision: 1.108 $"); + version = odr_strdup(assoc->encode, "$Revision: 1.109 $"); if (strlen(version) > 10) /* check for unexpanded CVS strings */ version[strlen(version)-2] = '\0'; resp->implementationVersion = odr_prepend(assoc->encode, @@ -2634,13 +2645,15 @@ static Z_APDU *process_searchRequest(association *assoc, request *reqb, bsrr->srw_sortKeys = 0; bsrr->srw_setname = 0; bsrr->srw_setnameIdleTime = 0; + bsrr->estimated_hit_count = 0; + bsrr->partial_resultset = 0; yaz_log (log_requestdetail, "ResultSet '%s'", req->resultSetName); if (req->databaseNames) { int i; for (i = 0; i < req->num_databaseNames; i++) - yaz_log (log_requestdetail, "Database '%s'", req->databaseNames[i]); + yaz_log(log_requestdetail, "Database '%s'", req->databaseNames[i]); } yaz_log_zquery_level(log_requestdetail,req->query); @@ -2702,10 +2715,9 @@ static Z_APDU *response_searchRequest(association *assoc, request *reqb, Z_SearchResponse *resp = (Z_SearchResponse *) odr_malloc (assoc->encode, sizeof(*resp)); int *nulint = odr_intdup (assoc->encode, 0); - bool_t *sr = odr_intdup(assoc->encode, 1); int *next = odr_intdup(assoc->encode, 0); int *none = odr_intdup(assoc->encode, Z_SearchResponse_none); - int returnedrecs=0; + int returnedrecs = 0; apdu->which = Z_APDU_searchResponse; apdu->u.searchResponse = resp; @@ -2730,8 +2742,8 @@ static Z_APDU *response_searchRequest(association *assoc, request *reqb, } else { + bool_t *sr = odr_intdup(assoc->encode, 1); int *toget = odr_intdup(assoc->encode, 0); - int *presst = odr_intdup(assoc->encode, 0); Z_RecordComposition comp, *compp = 0; yaz_log (log_requestdetail, "resultCount: %d", bsrt->hits); @@ -2762,6 +2774,7 @@ static Z_APDU *response_searchRequest(association *assoc, request *reqb, { oident *prefformat; oid_value form; + int *presst = odr_intdup(assoc->encode, 0); if (!(prefformat = oid_getentbyoid(req->preferredRecordSyntax))) form = VAL_NONE; @@ -2804,9 +2817,6 @@ static Z_APDU *response_searchRequest(association *assoc, request *reqb, return 0; resp->numberOfRecordsReturned = toget; returnedrecs = *toget; - resp->nextResultSetPosition = next; - resp->searchStatus = sr; - resp->resultSetStatus = 0; resp->presentStatus = presst; } else @@ -2814,11 +2824,21 @@ static Z_APDU *response_searchRequest(association *assoc, request *reqb, if (*resp->resultCount) *next = 1; resp->numberOfRecordsReturned = nulint; - resp->nextResultSetPosition = next; - resp->searchStatus = sr; - resp->resultSetStatus = 0; resp->presentStatus = 0; } + resp->nextResultSetPosition = next; + resp->searchStatus = sr; + resp->resultSetStatus = 0; + if (bsrt->estimated_hit_count) + { + resp->resultSetStatus = odr_intdup(assoc->encode, + Z_SearchResponse_estimate); + } + else if (bsrt->partial_resultset) + { + resp->resultSetStatus = odr_intdup(assoc->encode, + Z_SearchResponse_subset); + } } resp->additionalSearchInfo = bsrt->search_info; diff --git a/src/z3950v3.asn b/src/z3950v3.asn index 98cf885..7dc3d4c 100644 --- a/src/z3950v3.asn +++ b/src/z3950v3.asn @@ -249,7 +249,9 @@ SearchResponse ::= SEQUENCE{ resultSetStatus [26] IMPLICIT INTEGER{ subset (1), interim (2), - none (3)} OPTIONAL, + none (3), + estimate(4) + } OPTIONAL, presentStatus PresentStatus OPTIONAL, records Records OPTIONAL, -- Following two parameters may be used only if version 3 is in force. diff --git a/ztest/ztest.c b/ztest/ztest.c index 1963764..dacf640 100644 --- a/ztest/ztest.c +++ b/ztest/ztest.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: ztest.c,v 1.84 2007-01-03 08:42:18 adam Exp $ + * $Id: ztest.c,v 1.85 2007-01-16 14:12:38 adam Exp $ */ /* @@ -66,7 +66,7 @@ int ztest_search(void *handle, bend_search_rr *rr) sleep(1); } #endif - ; + rr->estimated_hit_count = 1; } else {