Allow mergekey to be given for command=search
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 6 May 2013 13:35:57 +0000 (15:35 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 6 May 2013 13:35:57 +0000 (15:35 +0200)
doc/pazpar2_protocol.xml
src/http_command.c
src/session.c
src/session.h
test/test_http.urls
test/test_http_88.res

index 8fb88cf..e227354 100644 (file)
@@ -390,6 +390,26 @@ search.pz2?session=2044502273&command=stat
      </varlistentry>
 
      <varlistentry>
+      <term>mergekey</term>
+      <listitem>
+       <para>
+       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
+       <literal>mergekey="optional"</literal> 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.
+       </para>
+       <para>
+       This facility, "dynamic mergekey", appeared in Pazpar2 version
+       1.6.31.
+       </para>
+      </listitem>
+     </varlistentry>
+
+     <varlistentry>
       <term>sort</term>
       <listitem>
        <para>
@@ -424,7 +444,7 @@ search.pz2?session=2044502273&command=stat
       <listitem>
        <para>
        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
        <literal>mergekey="optional"</literal> inside a metadata element.
index 5353e84..004abba 100644 (file)
@@ -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);
index ed80133..187ae38 100644 (file)
@@ -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);
 
index af73f03..ad94e29 100644 (file)
@@ -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,
index c641fd0..c57a926 100644 (file)
@@ -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=
index 837a9ff..7829578 100644 (file)
@@ -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);
  </relevance_info>
- <recid>content: title how to program a computer author jack collins medium book</recid>
+ <recid>content: title how to program a computer author jack collins</recid>
 </hit>
 <hit>
  <md-title>Computer science &amp; technology</md-title>
@@ -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);
  </relevance_info>
- <recid>content: title computer science technology author medium book</recid>
+ <recid>content: title computer science technology</recid>
 </hit>
 <hit>
  <md-title>The Computer Bible</md-title>
@@ -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);
  </relevance_info>
- <recid>content: title the computer bible author medium book</recid>
+ <recid>content: title the computer bible</recid>
 </hit>
 <hit>
  <md-title>A plan for community college computer development</md-title>
@@ -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);
  </relevance_info>
- <recid>content: title a plan for community college computer development author medium book</recid>
+ <recid>content: title a plan for community college computer development</recid>
 </hit>
 <hit>
  <md-title>Washington metropolitan area rail computer feasibility study;</md-title>
@@ -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);
  </relevance_info>
- <recid>content: title washington metropolitan area rail computer feasibility study author englund carl r medium book</recid>
+ <recid>content: title washington metropolitan area rail computer feasibility study author englund carl r</recid>
 </hit>
 <hit>
  <md-title>The Puget Sound Region</md-title>
@@ -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);
  </relevance_info>
- <recid>content: title the puget sound region author mairs john w medium book</recid>
+ <recid>content: title the puget sound region author mairs john w</recid>
 </hit>
 <hit>
  <md-title>Computer processing of dynamic images from an Anger scintillation camera</md-title>
@@ -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);
  </relevance_info>
- <recid>content: title computer processing of dynamic images from an anger scintillation camera author medium book</recid>
+ <recid>content: title computer processing of dynamic images from an anger scintillation camera</recid>
 </hit>
 <hit>
  <md-title>The use of passwords for controlled access to computer resources</md-title>
@@ -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);
  </relevance_info>
- <recid>content: title the use of passwords for controlled access to computer resources author wood helen m medium book</recid>
+ <recid>content: title the use of passwords for controlled access to computer resources author wood helen m</recid>
 </hit>
 <hit>
  <md-title>Reconstruction tomography in diagnostic radiology and nuclear medicine</md-title>
@@ -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);
  </relevance_info>
- <recid>content: title reconstruction tomography in diagnostic radiology and nuclear medicine author medium book</recid>
+ <recid>content: title reconstruction tomography in diagnostic radiology and nuclear medicine</recid>
 </hit>
 </show>
\ No newline at end of file