From f1af7094481beba15c9ce3349095681db5981b28 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 6 May 2013 15:35:57 +0200 Subject: [PATCH] Allow mergekey to be given for command=search --- doc/pazpar2_protocol.xml | 22 +++++++++++++++++++++- src/http_command.c | 3 ++- src/session.c | 9 ++++++++- src/session.h | 3 ++- test/test_http.urls | 2 +- test/test_http_88.res | 18 +++++++++--------- 6 files changed, 43 insertions(+), 14 deletions(-) diff --git a/doc/pazpar2_protocol.xml b/doc/pazpar2_protocol.xml index 8fb88cf..e227354 100644 --- a/doc/pazpar2_protocol.xml +++ b/doc/pazpar2_protocol.xml @@ -390,6 +390,26 @@ search.pz2?session=2044502273&command=stat + mergekey + + + Sets mergekey for this search and rest of session, or until + another mergekey is given for show/search. The mergekey value is a + comma separated list with one or more names as they appear + in the service description equivalent to + mergekey="optional" inside a metadata element. + If the empty string is given for mergekey it is disabled + and rest of session will use the default mergekey from service + or stylesheet. + + + This facility, "dynamic mergekey", appeared in Pazpar2 version + 1.6.31. + + + + + sort @@ -424,7 +444,7 @@ search.pz2?session=2044502273&command=stat Sets mergekey for this show and rest of session, or until - another mergekey is given for show. The mergekey value is a + another mergekey is given for show/search. The mergekey value is a comma separated list with one or more names as they appear in the service description equivalent to mergekey="optional" inside a metadata element. diff --git a/src/http_command.c b/src/http_command.c index 5353e84..004abba 100644 --- a/src/http_command.c +++ b/src/http_command.c @@ -1322,6 +1322,7 @@ static void cmd_search(struct http_channel *c) const char *startrecs = http_argbyname(rq, "startrecs"); const char *limit = http_argbyname(rq, "limit"); const char *sort = http_argbyname(rq, "sort"); + const char *mergekey = http_argbyname(rq, "mergekey"); enum pazpar2_error_code code; const char *addinfo = 0; struct reclist_sortparms *sp; @@ -1354,7 +1355,7 @@ static void cmd_search(struct http_channel *c) } code = session_search(s->psession, query, startrecs, maxrecs, filter, limit, - &addinfo, sp); + &addinfo, sp, mergekey); if (code) { error(rs, code, addinfo); diff --git a/src/session.c b/src/session.c index ed80133..187ae38 100644 --- a/src/session.c +++ b/src/session.c @@ -752,7 +752,8 @@ enum pazpar2_error_code session_search(struct session *se, const char *filter, const char *limit, const char **addinfo, - struct reclist_sortparms *sp) + struct reclist_sortparms *sp, + const char *mergekey) { int live_channels = 0; int no_working = 0; @@ -773,6 +774,12 @@ enum pazpar2_error_code session_search(struct session *se, session_enter(se, "session_search"); se->settings_modified = 0; + if (mergekey) + { + xfree(se->mergekey); + se->mergekey = *mergekey ? xstrdup(mergekey) : 0; + } + session_clear_set(se, sp); relevance_destroy(&se->relevance); diff --git a/src/session.h b/src/session.h index af73f03..ad94e29 100644 --- a/src/session.h +++ b/src/session.h @@ -168,7 +168,8 @@ enum pazpar2_error_code session_search(struct session *s, const char *query, const char *maxrecs, const char *filter, const char *limit, const char **addinfo, - struct reclist_sortparms *sort_parm); + struct reclist_sortparms *sort_parm, + const char *mergekey); struct record_cluster **show_range_start(struct session *s, struct reclist_sortparms *sp, int start, diff --git a/test/test_http.urls b/test/test_http.urls index c641fd0..c57a926 100644 --- a/test/test_http.urls +++ b/test/test_http.urls @@ -84,7 +84,7 @@ http://localhost:9763/search.pz2?session=10&command=search&query=teachers&limit= http://localhost:9763/search.pz2?session=10&command=show&block=1 http://localhost:9763/search.pz2?session=10&command=record&id=content%3A+title+the+religious+teachers+of+greece+author+adam+james+medium+book&offset=0&esn=F&r=1 http://localhost:9763/search.pz2?session=10&command=record&id=content%3A+title+the+religious+teachers+of+greece+author+adam+james+medium+book&offset=0&esn=F&r=2 -http://localhost:9763/search.pz2?session=10&command=search&query=computer +http://localhost:9763/search.pz2?session=10&command=search&query=computer&mergekey=title,author http://localhost:9763/search.pz2?session=10&command=show&block=1 http://localhost:9763/search.pz2?session=10&command=show&block=1&mergekey=date http://localhost:9763/search.pz2?session=10&command=show&block=1&mergekey= diff --git a/test/test_http_88.res b/test/test_http_88.res index 837a9ff..7829578 100644 --- a/test/test_http_88.res +++ b/test/test_http_88.res @@ -38,7 +38,7 @@ idf[1] = log(((1 + total(10))/termoccur(9)); computer: relevance += 100000 * tf[1](2.400000) * idf[1](0.200671) (48160); score = relevance(48160); - content: title how to program a computer author jack collins medium book + content: title how to program a computer author jack collins Computer science & technology @@ -69,7 +69,7 @@ idf[1] = log(((1 + total(10))/termoccur(9)); computer: relevance += 100000 * tf[1](2.000000) * idf[1](0.200671) (40134); score = relevance(40134); - content: title computer science technology author medium book + content: title computer science technology The Computer Bible @@ -100,7 +100,7 @@ idf[1] = log(((1 + total(10))/termoccur(9)); computer: relevance += 100000 * tf[1](2.000000) * idf[1](0.200671) (40134); score = relevance(40134); - content: title the computer bible author medium book + content: title the computer bible A plan for community college computer development @@ -136,7 +136,7 @@ idf[1] = log(((1 + total(10))/termoccur(9)); computer: relevance += 100000 * tf[1](0.857143) * idf[1](0.200671) (17200); score = relevance(17200); - content: title a plan for community college computer development author medium book + content: title a plan for community college computer development Washington metropolitan area rail computer feasibility study; @@ -171,7 +171,7 @@ idf[1] = log(((1 + total(10))/termoccur(9)); computer: relevance += 100000 * tf[1](0.857143) * idf[1](0.200671) (17200); score = relevance(17200); - content: title washington metropolitan area rail computer feasibility study author englund carl r medium book + content: title washington metropolitan area rail computer feasibility study author englund carl r The Puget Sound Region @@ -209,7 +209,7 @@ idf[1] = log(((1 + total(10))/termoccur(9)); computer: relevance += 100000 * tf[1](0.833333) * idf[1](0.200671) (16722); score = relevance(16722); - content: title the puget sound region author mairs john w medium book + content: title the puget sound region author mairs john w Computer processing of dynamic images from an Anger scintillation camera @@ -252,7 +252,7 @@ idf[1] = log(((1 + total(10))/termoccur(9)); computer: relevance += 100000 * tf[1](0.600000) * idf[1](0.200671) (12040); score = relevance(12040); - content: title computer processing of dynamic images from an anger scintillation camera author medium book + content: title computer processing of dynamic images from an anger scintillation camera The use of passwords for controlled access to computer resources @@ -283,7 +283,7 @@ idf[1] = log(((1 + total(10))/termoccur(9)); computer: relevance += 100000 * tf[1](0.600000) * idf[1](0.200671) (12040); score = relevance(12040); - content: title the use of passwords for controlled access to computer resources author wood helen m medium book + content: title the use of passwords for controlled access to computer resources author wood helen m Reconstruction tomography in diagnostic radiology and nuclear medicine @@ -313,6 +313,6 @@ idf[1] = log(((1 + total(10))/termoccur(9)); computer: relevance += 100000 * tf[1](0.000000) * idf[1](0.200671) (0); score = relevance(0); - content: title reconstruction tomography in diagnostic radiology and nuclear medicine author medium book + content: title reconstruction tomography in diagnostic radiology and nuclear medicine \ No newline at end of file -- 1.7.10.4