Merge branch 'protocol-version2' of ssh://git.indexdata.com/home/git/pub/pazpar2...
[pazpar2-moved-to-github.git] / src / client.c
index 26dd6ef..5635083 100644 (file)
@@ -758,13 +758,12 @@ void client_start_search(struct client *cl)
     const char *opt_preferred   = session_setting_oneval(sdb, PZ_PREFERRED);
     const char *extra_args      = session_setting_oneval(sdb, PZ_EXTRA_ARGS);
     const char *opt_present_chunk = session_setting_oneval(sdb, PZ_PRESENT_CHUNK);
-    /* Default present chunk */
-    int present_chunk = 20;
+    ZOOM_query q;
+    char maxrecs_str[24], startrecs_str[24], present_chunk_str[24];
+    int present_chunk = 20; // Default chunk size
     if (opt_present_chunk && strcmp(opt_present_chunk,"")) {
         present_chunk = atoi(opt_present_chunk);
     }
-    char maxrecs_str[24], startrecs_str[24], present_chunk_str[24];
-    ZOOM_query q;
 
     assert(link);
 
@@ -1327,6 +1326,14 @@ Odr_int client_get_hits(struct client *cl)
     return cl->hits;
 }
 
+Odr_int client_get_approximation(struct client *cl)
+{
+    int records = cl->record_offset + cl->filtered;
+    if (records > 0)
+        return cl->hits * cl->record_offset / records;
+    return cl->hits;
+}
+
 int client_get_num_records(struct client *cl)
 {
     return cl->record_offset;