From: Adam Dickmeiss Date: Mon, 16 Jul 2007 17:01:46 +0000 (+0000) Subject: The record ID (recid) that Pazpar2 generates is now the merge key and not X-Git-Tag: PAZPAR2.1.0.2~48 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=a085694d89c72f473733b58d08ddc2f5b37390e2;p=pazpar2-moved-to-github.git The record ID (recid) that Pazpar2 generates is now the merge key and not a dynamically generated integer. It allows us to repeat the search and still be able to get hold of the record again. A little more persistent. --- diff --git a/src/http_command.c b/src/http_command.c index b024f86..087f53d 100644 --- a/src/http_command.c +++ b/src/http_command.c @@ -1,4 +1,4 @@ -/* $Id: http_command.c,v 1.56 2007-07-03 11:21:48 adam Exp $ +/* $Id: http_command.c,v 1.57 2007-07-16 17:01:46 adam Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -20,7 +20,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA */ /* - * $Id: http_command.c,v 1.56 2007-07-03 11:21:48 adam Exp $ + * $Id: http_command.c,v 1.57 2007-07-16 17:01:46 adam Exp $ */ #include @@ -533,8 +533,6 @@ static void cmd_record(struct http_channel *c) const char *idstr = http_argbyname(rq, "id"); const char *offsetstr = http_argbyname(rq, "offset"); - int id; - if (!s) return; if (!idstr) @@ -543,8 +541,7 @@ static void cmd_record(struct http_channel *c) return; } wrbuf_rewind(c->wrbuf); - id = atoi(idstr); - if (!(rec = show_single(s->psession, id))) + if (!(rec = show_single(s->psession, idstr))) { error(rs, PAZPAR2_RECORD_MISSING, idstr); return; @@ -582,7 +579,7 @@ static void cmd_record(struct http_channel *c) else { wrbuf_puts(c->wrbuf, "\n"); - wrbuf_printf(c->wrbuf, "%d\n", rec->recid); + wrbuf_printf(c->wrbuf, "%s\n", rec->recid); write_metadata(c->wrbuf, service, rec->metadata, 1); for (r = rec->records; r; r = r->next) write_subrecord(r, c->wrbuf, service, 1); @@ -650,7 +647,7 @@ static void show_records(struct http_channel *c, int active) write_subrecord(p, c->wrbuf, service, 0); // subrecs w/o details if (ccount > 1) wrbuf_printf(c->wrbuf, "%d\n", ccount); - wrbuf_printf(c->wrbuf, "%d\n", rec->recid); + wrbuf_printf(c->wrbuf, "%s\n", rec->recid); wrbuf_puts(c->wrbuf, "\n"); } diff --git a/src/logic.c b/src/logic.c index d5e8cf9..eae862b 100644 --- a/src/logic.c +++ b/src/logic.c @@ -1,4 +1,4 @@ -/* $Id: logic.c,v 1.53 2007-07-16 09:09:56 adam Exp $ +/* $Id: logic.c,v 1.54 2007-07-16 17:01:46 adam Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -797,13 +797,13 @@ void report_nmem_stats(void) } #endif -struct record_cluster *show_single(struct session *s, int id) +struct record_cluster *show_single(struct session *s, const char *id) { struct record_cluster *r; reclist_rewind(s->reclist); while ((r = reclist_read_record(s->reclist))) - if (r->recid == id) + if (!strcmp(r->recid, id)) return r; return 0; } @@ -1016,7 +1016,7 @@ struct record *ingest_record(struct client *cl, Z_External *rec, record, (char *) mergekey_norm, &se->total_merged); if (global_parameters.dump_records) - yaz_log(YLOG_LOG, "Cluster id %d from %s (#%d)", cluster->recid, + yaz_log(YLOG_LOG, "Cluster id %s from %s (#%d)", cluster->recid, client_get_database(cl)->database->url, record_no); if (!cluster) { diff --git a/src/pazpar2.h b/src/pazpar2.h index 96f2291..760d034 100644 --- a/src/pazpar2.h +++ b/src/pazpar2.h @@ -1,4 +1,4 @@ -/* $Id: pazpar2.h,v 1.44 2007-06-28 09:36:10 adam Exp $ +/* $Id: pazpar2.h,v 1.45 2007-07-16 17:01:46 adam Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -177,7 +177,7 @@ enum pazpar2_error_code search(struct session *s, char *query, 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); -struct record_cluster *show_single(struct session *s, int id); +struct record_cluster *show_single(struct session *s, const char *id); struct termlist_score **termlist(struct session *s, const char *name, int *num); int session_set_watch(struct session *s, int what, session_watchfun fun, void *data, struct http_channel *c); int session_active_clients(struct session *s); diff --git a/src/reclists.c b/src/reclists.c index 3d4c7fc..ec591b1 100644 --- a/src/reclists.c +++ b/src/reclists.c @@ -1,4 +1,4 @@ -/* $Id: reclists.c,v 1.18 2007-07-02 20:55:50 adam Exp $ +/* $Id: reclists.c,v 1.19 2007-07-16 17:01:46 adam Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -268,7 +268,7 @@ struct reclist *reclist_create(NMEM nmem, int numrecs) struct record_cluster *reclist_insert( struct reclist *l, struct conf_service *service, struct record *record, - const char *merge_key, int *total) + char *merge_key, int *total) { unsigned int bucket; struct reclist_bucket **p; @@ -305,10 +305,11 @@ struct record_cluster *reclist_insert( struct reclist *l, new->record = newc; new->next = 0; newc->records = record; - newc->merge_key = (char *) merge_key; + newc->merge_key = merge_key; newc->relevance = 0; newc->term_frequency_vec = 0; - newc->recid = (*total)++; + newc->recid = merge_key; + (*total)++; newc->metadata = nmem_malloc(l->nmem, sizeof(struct record_metadata*) * service->num_metadata); memset(newc->metadata, 0, diff --git a/src/reclists.h b/src/reclists.h index 4b0e450..2661cd8 100644 --- a/src/reclists.h +++ b/src/reclists.h @@ -1,4 +1,4 @@ -/* $Id: reclists.h,v 1.10 2007-04-25 13:09:17 marc Exp $ +/* $Id: reclists.h,v 1.11 2007-07-16 17:01:46 adam Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -68,7 +68,7 @@ struct reclist *reclist_create(NMEM, int numrecs); struct record_cluster *reclist_insert( struct reclist *tl, struct conf_service *service, struct record *record, - const char *merge_key, int *total); + char *merge_key, int *total); void reclist_sort(struct reclist *l, struct reclist_sortparms *parms); struct record_cluster *reclist_read_record(struct reclist *l); void reclist_rewind(struct reclist *l); diff --git a/src/record.h b/src/record.h index c915442..ac1e14b 100644 --- a/src/record.h +++ b/src/record.h @@ -1,4 +1,4 @@ -/* $Id: record.h,v 1.10 2007-06-13 21:29:04 adam Exp $ +/* $Id: record.h,v 1.11 2007-07-16 17:01:46 adam Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -108,7 +108,7 @@ struct record_cluster int relevance; int *term_frequency_vec; // Set-specific ID for this record - int recid; + char *recid; struct record *records; }; diff --git a/test/test_http_5.res b/test/test_http_5.res index b887fa9..b71a436 100644 --- a/test/test_http_5.res +++ b/test/test_http_5.res @@ -11,21 +11,21 @@ Jack Collins 2 -0 +title how to program a computer author jack collins medium book The use of passwords for controlled access to computer resources 1977 Wood, Helen M -6 +title the use of passwords for controlled access to computer resources author wood helen m medium book A plan for community college computer development 1971 Cover title -8 +title a plan for community college computer development author medium book @@ -34,21 +34,21 @@ 1971 Englund, Carl R "Contract DOT-UT-10003." -7 +title washington metropolitan area rail computer feasibility study author englund carl r medium book The Computer Bible 1973-1980 Vols. 2, 8: Missoula, Mont. : Published by Scholars Press for Biblical Research Associates -2 +title the computer bible author medium book Computer science & technology proceedings of a workshop held at the National Bureau of Standards, Gaithersburg, MD, June 3-4, 1976 1977 -5 +title computer science technology author medium book @@ -57,7 +57,7 @@ 1974 Mairs, John W Scale of maps ca. 1:1,000,000 -3 +title the puget sound region author mairs john w medium book @@ -65,7 +65,7 @@ the proceedings of a workshop 1974 Includes bibliographical references and index -1 +title computer processing of dynamic images from an anger scintillation camera author medium book @@ -73,6 +73,6 @@ proceedings of the workshop 1977 Includes bibliographical references and index -4 +title reconstruction tomography in diagnostic radiology and nuclear medicine author medium book diff --git a/test/test_http_6.res b/test/test_http_6.res index 4fc8f51..d1aae07 100644 --- a/test/test_http_6.res +++ b/test/test_http_6.res @@ -1,5 +1,5 @@ -0 +title how to program a computer author jack collins medium book How to program a computer Jack Collins diff --git a/test/test_http_urls b/test/test_http_urls index fe1f8f3..cd820a4 100644 --- a/test/test_http_urls +++ b/test/test_http_urls @@ -4,5 +4,5 @@ http://localhost:9763/search.pz2?session=1&command=ping http://localhost:9763/search.pz2?session=1&command=search&query=computer 2 http://localhost:9763/search.pz2?session=1&command=show&start=0&number=1&block=1 -http://localhost:9763/search.pz2?session=1&command=record&id=0 -http://localhost:9763/search.pz2?session=1&command=record&id=0&offset=0 +http://localhost:9763/search.pz2?session=1&command=record&id=title+how+to+program+a+computer+author+jack+collins+medium+book +http://localhost:9763/search.pz2?session=1&command=record&id=title+how+to+program+a+computer+author+jack+collins+medium+book&offset=0 diff --git a/www/jsdemo/example_client.js b/www/jsdemo/example_client.js index 9d3984b..dc10ad1 100644 --- a/www/jsdemo/example_client.js +++ b/www/jsdemo/example_client.js @@ -1,5 +1,5 @@ /* A very simple client that shows a basic usage of the pz2.js -** $Id: example_client.js,v 1.3 2007-07-16 09:39:56 adam Exp $ +** $Id: example_client.js,v 1.4 2007-07-16 17:01:46 adam Exp $ */ // create a parameters array and pass it to the pz2's constructor @@ -19,7 +19,7 @@ my_paz = new pz2( { "onshow": my_onshow, var curPage = 1; var recPerPage = 20; var totalRec = 0; -var curDetRecId = -1; +var curDetRecId = ''; var curDetRecData = null; // wait until the DOM is ready @@ -34,7 +34,7 @@ function domReady () function onFormSubmitEventHandler() { curPage = 1; - curDetRecId = -1; + curDetRecId = ''; totalRec = 0; my_paz.search(document.search.query.value, recPerPage, 'relevance'); return false; @@ -142,7 +142,7 @@ function my_onbytarget(data) { // detailed record drawing function showDetails ( prefixRecId ) { - var recId = Number(prefixRecId.replace('rec_', '')); + var recId = prefixRecId.replace('rec_', ''); // remove current detailed view if any var detRecordDiv = document.getElementById('det_'+curDetRecId); @@ -152,7 +152,7 @@ function showDetails ( prefixRecId ) { // if the same clicked do not redraw if ( recId == curDetRecId ) { - curDetRecId = -1; + curDetRecId = ''; return; } @@ -170,7 +170,7 @@ function drawCurDetails () '">
Ttle: '+data["md-title"] + "
Date: " + data["md-date"] + "
Author: " + data["md-author"] + - '
URL: ' + data["md-url"] + '' + + '
URL: ' + data["md-electronic-url"] + '' + "
Subject: " + data["md-subject"] + "
Location: " + data["location"][0].name + "
";