From: Adam Dickmeiss Date: Mon, 12 Oct 2009 14:21:19 +0000 (+0200) Subject: New optional argument, startrecs, for cmd=search X-Git-Tag: v1.2.2~7 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=83518ddb5165d783b37a0244bb0f3c79cd1b8398;p=pazpar2-moved-to-github.git New optional argument, startrecs, for cmd=search --- diff --git a/src/client.c b/src/client.c index a7d069d..e3b34cb 100644 --- a/src/client.c +++ b/src/client.c @@ -75,6 +75,7 @@ struct client { int hits; int record_offset; int maxrecs; + int startrecs; int diagnostic; enum client_state state; struct show_raw *show_raw; @@ -404,7 +405,7 @@ void client_search_response(struct client *cl) } else { - cl->record_offset = 0; + cl->record_offset = cl->startrecs; cl->hits = ZOOM_resultset_size(resultset); se->total_hits += cl->hits; } @@ -527,11 +528,20 @@ void client_start_search(struct client *cl) } ZOOM_connection_option_set(link, "count", opt_maxrecs); + if (atoi(opt_maxrecs) > 20) ZOOM_connection_option_set(link, "presentChunk", "20"); else ZOOM_connection_option_set(link, "presentChunk", opt_maxrecs); + + if (cl->startrecs) + { + char startrecs_str[24]; + sprintf(startrecs_str, "%d", cl->startrecs); + ZOOM_connection_option_set(link, "start", startrecs_str); + } + if (databaseName) ZOOM_connection_option_set(link, "databaseName", databaseName); @@ -566,6 +576,7 @@ struct client *client_create(void) else r = xmalloc(sizeof(struct client)); r->maxrecs = 100; + r->startrecs = 0; r->pquery = 0; r->cqlquery = 0; r->database = 0; @@ -794,6 +805,11 @@ void client_set_maxrecs(struct client *cl, int v) cl->maxrecs = v; } +void client_set_startrecs(struct client *cl, int v) +{ + cl->startrecs = v; +} + /* * Local variables: * c-basic-offset: 4 diff --git a/src/client.h b/src/client.h index d996cd6..93b2e32 100644 --- a/src/client.h +++ b/src/client.h @@ -86,6 +86,7 @@ void client_set_database(struct client *cl, struct session_database *db); struct host *client_get_host(struct client *cl); const char *client_get_url(struct client *cl); void client_set_maxrecs(struct client *cl, int v); +void client_set_startrecs(struct client *cl, int v); #endif diff --git a/src/http_command.c b/src/http_command.c index 7cbcda6..37ad0bc 100644 --- a/src/http_command.c +++ b/src/http_command.c @@ -871,6 +871,7 @@ static void cmd_search(struct http_channel *c) const char *query = http_argbyname(rq, "query"); const char *filter = http_argbyname(rq, "filter"); const char *maxrecs = http_argbyname(rq, "maxrecs"); + const char *startrecs = http_argbyname(rq, "startrecs"); enum pazpar2_error_code code; const char *addinfo = 0; @@ -886,7 +887,7 @@ static void cmd_search(struct http_channel *c) error(rs, PAZPAR2_MALFORMED_PARAMETER_ENCODING, "query"); return; } - code = search(s->psession, query, maxrecs, filter, &addinfo); + code = search(s->psession, query, startrecs, maxrecs, filter, &addinfo); if (code) { error(rs, code, addinfo); diff --git a/src/logic.c b/src/logic.c index 2ee1203..cc09dd1 100644 --- a/src/logic.c +++ b/src/logic.c @@ -471,7 +471,7 @@ static struct database_criterion *parse_filter(NMEM m, const char *buf) enum pazpar2_error_code search(struct session *se, const char *query, - const char *maxrecs, + const char *startrecs, const char *maxrecs, const char *filter, const char **addinfo) { @@ -502,6 +502,8 @@ enum pazpar2_error_code search(struct session *se, { if (maxrecs) client_set_maxrecs(cl, atoi(maxrecs)); + if (startrecs) + client_set_startrecs(cl, atoi(startrecs)); if (prepare_session_database(se, client_get_database(cl)) < 0) continue; // Parse query for target diff --git a/src/pazpar2.h b/src/pazpar2.h index 028e5a7..0140ebc 100644 --- a/src/pazpar2.h +++ b/src/pazpar2.h @@ -163,7 +163,7 @@ void session_init_databases(struct session *s); int load_targets(struct session *s, const char *fn); void statistics(struct session *s, struct statistics *stat); enum pazpar2_error_code search(struct session *s, const char *query, - const char *maxrecs, + const char *startrecs, const char *maxrecs, const char *filter, const char **addinfo); struct record_cluster **show(struct session *s, struct reclist_sortparms *sp, int start, int *num, int *total, int *sumhits, NMEM nmem_show); diff --git a/test/test_http_42.res b/test/test_http_42.res index da57585..cb316c4 100644 --- a/test/test_http_42.res +++ b/test/test_http_42.res @@ -8,18 +8,34 @@ 5 -The Computer Bible -1973-1980 -Vols. 2, 8: Missoula, Mont. : Published by Scholars Press for Biblical Research Associates -The Computer Bible -1973-1980 -Hebrew and Greek; introductions in English -Vols. 2, 8: Missoula, Mont. : Published by Scholars Press for Biblical Research Associates +The religious teachers of Greece +1972 +Adam, James +Reprint of the 1909 ed., which was issued as the 1904-1906 Gifford lectures +The religious teachers of Greece +1972 +Adam, James +Reprint of the 1909 ed., which was issued as the 1904-1906 Gifford lectures +Includes bibliographical references XXXXXXXXXX test-usersetting-2 data: YYYYYYYYY -30000 -title the computer bible author medium book +48000 +title the religious teachers of greece author adam james medium book + + + +The use of passwords for controlled access to computer resources +1977 +Wood, Helen M +The use of passwords for controlled access to computer resources +1977 +Wood, Helen M +XXXXXXXXXX +test-usersetting-2 data: + YYYYYYYYY +42857 +title the use of passwords for controlled access to computer resources author wood helen m medium book @@ -70,20 +86,4 @@ 25000 title computer science technology author medium book - - -Computer processing of dynamic images from an Anger scintillation camera -the proceedings of a workshop -1974 -Includes bibliographical references and index -Computer processing of dynamic images from an Anger scintillation camera -the proceedings of a workshop -1974 -Includes bibliographical references and index -XXXXXXXXXX -test-usersetting-2 data: - YYYYYYYYY -17857 -title computer processing of dynamic images from an anger scintillation camera author medium book - diff --git a/test/test_http_urls b/test/test_http_urls index ebc6be9..fdb8a92 100644 --- a/test/test_http_urls +++ b/test/test_http_urls @@ -44,7 +44,7 @@ http://localhost:9763/search.pz2?session=5&command=show&start=0&number=1&block=1 http://localhost:9763/search.pz2?session=5&command=search&query=computer&filter=pz%3Aid%3Dunknown http://localhost:9763/search.pz2?session=3&command=settings&pz:maxrecs%5Bz3950.indexdata.com%2Fgils%5D=8 http://localhost:9763/search.pz2?session=3&command=search&query=the -http://localhost:9763/search.pz2?session=5&command=search&query=the&maxrecs=5 +http://localhost:9763/search.pz2?session=5&command=search&query=the&maxrecs=5&startrecs=2 2 http://localhost:9763/search.pz2?session=3&command=show&start=0&number=1&block=1 http://localhost:9763/search.pz2?session=5&command=show&start=0&number=1&block=1