termlist: generate empty <list/> for non-matched entries
authorAdam Dickmeiss <adam@indexdata.dk>
Thu, 8 Mar 2012 13:30:51 +0000 (14:30 +0100)
committerAdam Dickmeiss <adam@indexdata.dk>
Thu, 8 Mar 2012 13:30:51 +0000 (14:30 +0100)
This, partly, reverts 8b22d0dda50f29c25ec63e749b8c32738530498c .

src/session.c
test/test_facets_11.res
test/test_facets_17.res
test/test_facets_18.res
test/test_facets_24.res
test/test_facets_6.res

index 6dce5d9..16b7146 100644 (file)
@@ -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);
index 6045d02..009806d 100644 (file)
@@ -45,4 +45,5 @@
 <term><name>date8</name><frequency>20</frequency></term>
 <term><name>date9</name><frequency>10</frequency></term>
 </list>
+<list name="medium"/>
 </termlist>
\ No newline at end of file
index 7765713..085dbd7 100644 (file)
@@ -45,4 +45,5 @@
 <term><name>date8</name><frequency>20</frequency></term>
 <term><name>date9</name><frequency>10</frequency></term>
 </list>
+<list name="medium"/>
 </termlist>
\ No newline at end of file
index 7765713..085dbd7 100644 (file)
@@ -45,4 +45,5 @@
 <term><name>date8</name><frequency>20</frequency></term>
 <term><name>date9</name><frequency>10</frequency></term>
 </list>
+<list name="medium"/>
 </termlist>
\ No newline at end of file
index 512b81f..53eb749 100644 (file)
@@ -40,4 +40,5 @@
 <term><name>date8</name><frequency>20</frequency></term>
 <term><name>date9</name><frequency>10</frequency></term>
 </list>
+<list name="medium"/>
 </termlist>
\ No newline at end of file
index f78c7dc..bfef71d 100644 (file)
@@ -30,4 +30,5 @@
 <term><name>1973</name><frequency>1</frequency></term>
 <term><name>1980</name><frequency>1</frequency></term>
 </list>
+<list name="medium"/>
 </termlist>
\ No newline at end of file