Changed predicate for 500 subfields.
[pazpar2-moved-to-github.git] / src / logic.c
index 3d4de11..4239171 100644 (file)
@@ -847,6 +847,7 @@ struct session *new_session(NMEM nmem)
     session->relevance = 0;
     session->total_hits = 0;
     session->total_records = 0;
+    session->number_of_warnings_unknown_elements = 0;
     session->num_termlists = 0;
     session->reclist = 0;
     session->requestid = -1;
@@ -1016,7 +1017,7 @@ void statistics(struct session *se, struct statistics *stat)
     stat->num_clients = count;
 }
 
-void start_http_listener(void)
+int start_http_listener(void)
 {
     char hp[128] = "";
     struct conf_server *ser = global_parameters.server;
@@ -1033,7 +1034,7 @@ void start_http_listener(void)
             sprintf(hp + strlen(hp), "%d", ser->port);
         }
     }
-    http_init(hp);
+    return http_init(hp);
 }
 
 void start_proxy(void)
@@ -1225,8 +1226,10 @@ struct record *ingest_record(struct client *cl, Z_External *rec,
                          value, type);
                  continue;
              }
-             rec_md->next = record->metadata[md_field_id];
-             record->metadata[md_field_id] = rec_md;
+             wheretoput = &record->metadata[md_field_id];
+             while (*wheretoput)
+                 wheretoput = &(*wheretoput)->next;
+             *wheretoput = rec_md;
 
              // merged metadata
              rec_md = record_metadata_init(se->nmem, (char *) value,
@@ -1235,6 +1238,12 @@ struct record *ingest_record(struct client *cl, Z_External *rec,
 
              // and polulate with data:
              // assign cluster or record based on merge action
+             if (ser_md->merge == Metadata_merge_no)
+             {
+                 while (*wheretoput)
+                     wheretoput = &(*wheretoput)->next;
+                 *wheretoput = rec_md;
+             }
              if (ser_md->merge == Metadata_merge_unique)
              {
                  struct record_metadata *mnode;
@@ -1348,9 +1357,13 @@ struct record *ingest_record(struct client *cl, Z_External *rec,
             xmlFree(value);
             type = value = 0;
         }
-        else
-            yaz_log(YLOG_WARN,
-                    "Unexpected element %s in internal record", n->name);
+         else
+         {
+             if (se->number_of_warnings_unknown_elements == 0)
+                 yaz_log(YLOG_WARN,
+                         "Unexpected element in internal record: %s", n->name);
+             se->number_of_warnings_unknown_elements++;
+         }
     }
     if (type)
         xmlFree(type);