Reorder and removed wrong maxrecs settings
[pazpar2-moved-to-github.git] / src / session.c
index fcf29fa..60f3813 100644 (file)
@@ -747,7 +747,7 @@ enum pazpar2_error_code session_search(struct session *se,
                 session_log(se, YLOG_LOG, "client REUSE %s", client_get_id(cl));
                 client_reingest(cl);
             }
-            else
+            else if (r)
             {
                 session_log(se, YLOG_LOG, "client NEW %s", client_get_id(cl));
                 client_start_search(cl);
@@ -1069,7 +1069,8 @@ void perform_termlist(struct http_channel *c, struct session *se,
     for (j = 0; j < num_names; j++)
     {
         const char *tname;
-        
+        int must_generate_empty = 1; /* bug 5350 */
+
         for (i = 0; i < se->num_termlists; i++)
         {
             tname = se->termlists[i].name;
@@ -1081,6 +1082,7 @@ void perform_termlist(struct http_channel *c, struct session *se,
                 wrbuf_puts(c->wrbuf, "<list name=\"");
                 wrbuf_xmlputs(c->wrbuf, tname);
                 wrbuf_puts(c->wrbuf, "\">\n");
+                must_generate_empty = 0;
 
                 p = termlist_highscore(se->termlists[i].termlist, &len);
                 if (p)
@@ -1115,6 +1117,13 @@ void perform_termlist(struct http_channel *c, struct session *se,
 
             targets_termlist_nb(c->wrbuf, se, num, c->nmem);
             wrbuf_puts(c->wrbuf, "</list>\n");
+            must_generate_empty = 0;
+        }
+        if (must_generate_empty)
+        {
+            wrbuf_puts(c->wrbuf, "<list name=\"");
+            wrbuf_xmlputs(c->wrbuf, names[j]);
+            wrbuf_puts(c->wrbuf, "\"/>\n");
         }
     }
     session_leave(se);
@@ -1754,6 +1763,8 @@ static int ingest_to_cluster(struct client *cl,
             struct record_metadata *rec_md = 0;
             int md_field_id = -1;
             int sk_field_id = -1;
+            int rank = 0;
+            xmlChar *rank_str = 0;
             
             type = xmlGetProp(n, (xmlChar *) "type");
             value = xmlNodeListGetString(xdoc, n->children, 1);
@@ -1767,6 +1778,15 @@ static int ingest_to_cluster(struct client *cl,
                 continue;
             
             ser_md = &service->metadata[md_field_id];
+
+            rank_str = xmlGetProp(n, (xmlChar *) "rank");
+            if (rank_str)
+            {
+                rank = atoi((const char *) rank_str);
+                xmlFree(rank_str);
+            }
+            else
+                rank = ser_md->rank;
             
             if (ser_md->sortkey_offset >= 0)
             {
@@ -1866,10 +1886,11 @@ static int ingest_to_cluster(struct client *cl,
 
 
             // ranking of _all_ fields enabled ... 
-            if (ser_md->rank)
+            if (rank)
+            {
                 relevance_countwords(se->relevance, cluster, 
-                                     (char *) value, ser_md->rank,
-                                     ser_md->name);
+                                     (char *) value, rank, ser_md->name);
+            }
 
             // construct facets ... unless the client already has reported them
             if (ser_md->termlist && !client_has_facet(cl, (char *) type))