From: Sebastian Hammer Date: Mon, 27 Nov 2006 19:44:26 +0000 (+0000) Subject: Paging support, small bug fixes X-Git-Tag: before.append.child~123 X-Git-Url: http://lists.indexdata.com/cgi-bin?a=commitdiff_plain;ds=sidebyside;h=117cefc8fc4658f95dbf2b7464acbbb871e1769b;p=pazpar2-moved-to-github.git Paging support, small bug fixes --- diff --git a/http_command.c b/http_command.c index 518fd78..335f3dd 100644 --- a/http_command.c +++ b/http_command.c @@ -1,7 +1,7 @@ /* * stat->num_hits = s->total_hits; * stat->num_records = s->total_records; - * $Id: http_command.c,v 1.3 2006-11-27 14:35:15 quinn Exp $ + * $Id: http_command.c,v 1.4 2006-11-27 19:44:26 quinn Exp $ */ #include @@ -190,6 +190,8 @@ static void cmd_show(struct http_request *rq, struct http_response *rs) char *num = http_argbyname(rq, "num"); int startn = 0; int numn = 20; + int total; + int total_hits; int i; if (!s) @@ -200,10 +202,14 @@ static void cmd_show(struct http_request *rq, struct http_response *rs) if (num) numn = atoi(num); - rl = show(s->psession, startn, &numn); + rl = show(s->psession, startn, &numn, &total, &total_hits); wrbuf_rewind(c->wrbuf); wrbuf_puts(c->wrbuf, "\nOK\n"); + wrbuf_printf(c->wrbuf, "%d\n", total); + wrbuf_printf(c->wrbuf, "%d\n", total_hits); + wrbuf_printf(c->wrbuf, "%d\n", startn); + wrbuf_printf(c->wrbuf, "%d\n", numn); for (i = 0; i < numn; i++) { diff --git a/pazpar2.c b/pazpar2.c index b6c02ee..096ed09 100644 --- a/pazpar2.c +++ b/pazpar2.c @@ -1,4 +1,4 @@ -/* $Id: pazpar2.c,v 1.6 2006-11-27 14:35:15 quinn Exp $ */; +/* $Id: pazpar2.c,v 1.7 2006-11-27 19:44:26 quinn Exp $ */; #include #include @@ -575,7 +575,8 @@ static void extract_subject(struct session *s, const char *rec) assert(len < 1023); memcpy(buf, subfield, len); buf[len] = '\0'; - termlist_insert(s->termlist, buf); + if (*buf) + termlist_insert(s->termlist, buf); } } } @@ -1078,14 +1079,23 @@ struct termlist_score **termlist(struct session *s, int *num) return termlist_highscore(s->termlist, num); } -struct record **show(struct session *s, int start, int *num) +struct record **show(struct session *s, int start, int *num, int *total, int *sumhits) { struct record **recs = nmem_malloc(s->nmem, *num * sizeof(struct record *)); int i; - // FIXME -- skip initial records - relevance_prepare_read(s->relevance, s->reclist); + + *total = s->reclist->num_records; + *sumhits = s->total_hits; + + for (i = 0; i < start; i++) + if (!reclist_read_record(s->reclist)) + { + *num = 0; + return 0; + } + for (i = 0; i < *num; i++) { struct record *r = reclist_read_record(s->reclist); diff --git a/pazpar2.h b/pazpar2.h index b993327..790fd24 100644 --- a/pazpar2.h +++ b/pazpar2.h @@ -61,7 +61,7 @@ void session_destroy(struct session *s); int load_targets(struct session *s, const char *fn); void statistics(struct session *s, struct statistics *stat); char *search(struct session *s, char *query); -struct record **show(struct session *s, int start, int *num); +struct record **show(struct session *s, int start, int *num, int *total, int *sumhits); struct termlist_score **termlist(struct session *s, int *num); #endif