Added support for date-value termlists
[pazpar2-moved-to-github.git] / src / pazpar2.c
index 93be2e3..affac3f 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: pazpar2.c,v 1.37 2007-01-16 18:44:25 adam Exp $ */
+/* $Id: pazpar2.c,v 1.40 2007-01-17 14:01:19 quinn Exp $ */
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -517,6 +517,9 @@ static struct record *ingest_record(struct client *cl, Z_External *rec)
     normalize_mergekey(mergekey_norm, 0);
 
     cluster = reclist_insert(se->reclist, res, mergekey_norm, &se->total_merged);
+    if (global_parameters.dump_records)
+        yaz_log(YLOG_LOG, "Cluster id %d from %s (#%d)", cluster->recid,
+                cl->database->url, cl->records);
     if (!cluster)
     {
         /* no room for record */
@@ -664,7 +667,16 @@ static struct record *ingest_record(struct client *cl, Z_External *rec)
             if (md->rank)
                 relevance_countwords(se->relevance, cluster, value, md->rank);
             if (md->termlist)
-                add_facet(se, type, value);
+            {
+                if (md->type == Metadata_type_year)
+                {
+                    char year[64];
+                    sprintf(year, "%d", last);
+                    add_facet(se, type, year);
+                }
+                else
+                    add_facet(se, type, value);
+            }
             xmlFree(type);
             xmlFree(value);
             type = value = 0;
@@ -702,6 +714,7 @@ static void ingest_records(struct client *cl, Z_Records *r)
     {
         Z_NamePlusRecord *npr = rlist->records[i];
 
+        cl->records++;
         if (npr->which != Z_NamePlusRecord_databaseRecord)
         {
             yaz_log(YLOG_WARN, "Unexpected record type, probably diagnostic");
@@ -743,7 +756,6 @@ static void do_presentResponse(IOCHAN i, Z_APDU *a)
     if (!*r->presentStatus && cl->state != Client_Error)
     {
         yaz_log(YLOG_DEBUG, "Good Present response");
-        cl->records += *r->numberOfRecordsReturned;
         ingest_records(cl, r->records);
         cl->state = Client_Idle;
     }
@@ -1550,7 +1562,8 @@ int main(int argc, char **argv)
                         "    -h [host:]port          (REST protocol listener)\n"
                         "    -C cclconfig\n"
                         "    -s simpletargetfile\n"
-                        "    -p hostname[:portno]    (HTTP proxy)\n");
+                        "    -p hostname[:portno]    (HTTP proxy)\n"
+                        "    -d                      (show internal records)\n");
                exit(1);
        }
     }