Deal with resultCountPrecision - SRU 2.0
authorAdam Dickmeiss <adam@indexdata.dk>
Fri, 6 Sep 2013 10:13:32 +0000 (12:13 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Fri, 6 Sep 2013 10:13:32 +0000 (12:13 +0200)
include/yaz/srw.h
src/seshigh.c
src/srw.c
src/srwutil.c

index 743c1d0..7af2421 100644 (file)
@@ -102,6 +102,7 @@ typedef struct {
 
 typedef struct {
     Odr_int *numberOfRecords;
+    char *resultCountPrecision;
     char * resultSetId;
     Odr_int *resultSetIdleTime;
 
index 30bf9e2..07ee014 100644 (file)
@@ -1160,7 +1160,19 @@ static void srw_bend_search(association *assoc,
                     res->extraResponseData_buf = rr.extra_response_data;
                     res->extraResponseData_len = strlen(rr.extra_response_data);
                 }
-                if (rr.estimated_hit_count || rr.partial_resultset)
+                if (strcmp(res->srw_version, "2.") > 0)
+                {
+                    if (rr.estimated_hit_count)
+                        srw_res->resultCountPrecision =
+                            odr_strdup(assoc->encode, "estimate");
+                    else if (rr.partial_resultset)
+                        srw_res->resultCountPrecision =
+                            odr_strdup(assoc->encode, "minimum");
+                    else
+                        srw_res->resultCountPrecision =
+                            odr_strdup(assoc->encode, "exact");
+                }
+                else if (rr.estimated_hit_count || rr.partial_resultset)
                 {
                     yaz_add_srw_diagnostic(
                         assoc->encode,
index c88ace0..97cb05d 100644 (file)
--- a/src/srw.c
+++ b/src/srw.c
@@ -852,6 +852,7 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data,
                 odr_malloc(o, sizeof(*res));
 
             res->numberOfRecords = 0;
+            res->resultCountPrecision = 0;
             res->resultSetId = 0;
             res->resultSetIdleTime = 0;
             res->records = 0;
@@ -874,6 +875,9 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data,
                 else if (match_xsd_integer(ptr, "numberOfRecords", o,
                                            &res->numberOfRecords))
                     ;
+                else if (match_xsd_string(ptr, "resultCountPrecision", o,
+                                           &res->resultCountPrecision))
+                    ;
                 else if (match_xsd_string(ptr, "resultSetId", o,
                                           &res->resultSetId))
                     ;
@@ -1142,6 +1146,9 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data,
                 yaz_srw_diagnostics(o, rptr, &res->diagnostics,
                                     &res->num_diagnostics, client_data, ns);
             }
+            if (res->resultCountPrecision)
+                add_xsd_string(ptr, "resultCountPrecision",
+                               res->resultCountPrecision);
         }
         else if ((*p)->which == Z_SRW_explain_request)
         {
index 4eb9573..4f403a5 100644 (file)
@@ -773,6 +773,7 @@ Z_SRW_PDU *yaz_srw_get_pdu(ODR o, int which, const char *version)
         sr->u.response = (Z_SRW_searchRetrieveResponse *)
             odr_malloc(o, sizeof(*sr->u.response));
         sr->u.response->numberOfRecords = 0;
+        sr->u.response->resultCountPrecision = 0;
         sr->u.response->resultSetId = 0;
         sr->u.response->resultSetIdleTime = 0;
         sr->u.response->records = 0;