Fix incorrect results for test_cluster_9 PAZ-911
authorAdam Dickmeiss <adam@indexdata.dk>
Wed, 18 Dec 2013 09:10:35 +0000 (10:10 +0100)
committerAdam Dickmeiss <adam@indexdata.dk>
Wed, 18 Dec 2013 09:10:35 +0000 (10:10 +0100)
The problem was that record where checked for comparison even though
they shouldn't be - in case of cluster merge.

src/reclists.c
test/test_cluster_9.res

index f07a2cb..817c133 100644 (file)
@@ -496,21 +496,19 @@ struct record_cluster *reclist_insert(struct reclist *l,
                 // We found a matching record. Merge them
                 if (!strcmp(merge_key, mkr->value))
                 {
-                    struct record **re;
-
                     rb = *p;
-                    for (re = &rb->record->records; *re; re = &(*re)->next)
+                    if (!cluster)
                     {
-                        if ((*re)->client == record->client &&
-                            record_compare(record, *re, service))
+                        struct record **re;
+                        for (re = &rb->record->records; *re; re = &(*re)->next)
                         {
-                            yaz_mutex_leave(l->mutex);
-                            return 0;
+                            if ((*re)->client == record->client &&
+                                record_compare(record, *re, service))
+                            {
+                                yaz_mutex_leave(l->mutex);
+                                return 0;
+                            }
                         }
-                    }
-
-                    if (!cluster)
-                    {
                         cluster = rb->record;
                         *re = record;
                         record->next = 0;
index 0b6bbcc..d47758f 100644 (file)
@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <show><status>OK</status>
 <activeclients>0</activeclients>
-<merged>2</merged>
+<merged>1</merged>
 <total>4</total>
 <start>0</start>
-<num>2</num>
+<num>1</num>
 <hit>
  <md-author>Jack Collins</md-author>
  <md-medium>book</md-medium>
   <md-date>1995</md-date>
   <md-title>How to program a computer vol4</md-title>
  </location>
- <count>3</count>
- <relevance>0</relevance>
- <recid>content: author jack collins medium book title how to program a computer vol1</recid>
-</hit>
-<hit>
- <md-author>Jack Collins</md-author>
- <md-medium>book</md-medium>
- <md-date>1995</md-date>
- <md-title>How to program a computer vol3</md-title>
  <location id="localhost:9999"
     name="ztest" checksum="1482143625">
   <md-author>Jack Collins</md-author>
@@ -54,8 +45,8 @@
   <md-date>1995</md-date>
   <md-title>How to program a computer vol4</md-title>
  </location>
- <count>2</count>
+ <count>5</count>
  <relevance>0</relevance>
- <recid>content: author jack collins medium book title how to program a computer vol3</recid>
+ <recid>content: author jack collins medium book title how to program a computer vol1</recid>
 </hit>
 </show>
\ No newline at end of file