1 /* $Id: logic.c,v 1.22 2007-04-26 11:03:54 marc Exp $
2 Copyright (c) 2006-2007, Index Data.
4 This file is part of Pazpar2.
6 Pazpar2 is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2, or (at your option) any later
11 Pazpar2 is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with Pazpar2; see the file LICENSE. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23 \brief high-level logic; mostly user sessions and settings
31 #include <sys/socket.h>
37 #include <yaz/marcdisp.h>
38 #include <yaz/comstack.h>
39 #include <yaz/tcpip.h>
40 #include <yaz/proto.h>
41 #include <yaz/readconf.h>
42 #include <yaz/pquery.h>
43 #include <yaz/otherinfo.h>
44 #include <yaz/yaz-util.h>
46 #include <yaz/query-charset.h>
47 #include <yaz/querytowrbuf.h>
48 #if YAZ_VERSIONL >= 0x020163
49 #include <yaz/oid_db.h>
58 #include <yaz/timing.h>
61 #include <netinet/in.h>
66 #include "termlists.h"
68 #include "relevance.h"
76 // Note: Some things in this structure will eventually move to configuration
77 struct parameters global_parameters =
98 // Recursively traverse query structure to extract terms.
99 void pull_terms(NMEM nmem, struct ccl_rpn_node *n, char **termlist, int *num)
111 pull_terms(nmem, n->u.p[0], termlist, num);
112 pull_terms(nmem, n->u.p[1], termlist, num);
115 nmem_strsplit(nmem, " ", n->u.t.term, &words, &numwords);
116 for (i = 0; i < numwords; i++)
117 termlist[(*num)++] = words[i];
124 char *normalize_mergekey(char *buf, int skiparticle)
126 char *p = buf, *pout = buf;
131 char articles[] = "the den der die des an a "; // must end in space
133 while (*p && !isalnum(*p))
136 while (*p && *p != ' ' && pout - firstword < 62)
137 *(pout++) = tolower(*(p++));
140 if (!strstr(articles, firstword))
147 while (*p && !isalnum(*p))
150 *(pout++) = tolower(*(p++));
153 while (*p && !isalnum(*p))
160 while (pout > buf && *pout == ' ');
165 // Extract what appears to be years from buf, storing highest and
167 static int extract_years(const char *buf, int *first, int *last)
176 while (*buf && !isdigit(*buf))
179 for (e = buf; *e && isdigit(*e); e++)
183 int value = atoi(buf);
184 if (*first < 0 || value < *first)
186 if (*last < 0 || value > *last)
195 static void add_facet(struct session *s, const char *type, const char *value)
201 for (i = 0; i < s->num_termlists; i++)
202 if (!strcmp(s->termlists[i].name, type))
204 if (i == s->num_termlists)
206 if (i == SESSION_MAX_TERMLISTS)
208 yaz_log(YLOG_FATAL, "Too many termlists");
212 s->termlists[i].name = nmem_strdup(s->nmem, type);
213 s->termlists[i].termlist
214 = termlist_create(s->nmem, s->expected_maxrecs, 15);
215 s->num_termlists = i + 1;
217 termlist_insert(s->termlists[i].termlist, value);
220 xmlDoc *normalize_record(struct session_database *sdb, Z_External *rec)
222 struct database_retrievalmap *m;
223 struct database *db = sdb->database;
227 // First normalize to XML
232 if (rec->which != Z_External_octet)
234 yaz_log(YLOG_WARN, "Unexpected external branch, probably BER %s",
238 buf = (char*) rec->u.octet_aligned->buf;
239 len = rec->u.octet_aligned->len;
240 if (yaz_marc_read_iso2709(sdb->yaz_marc, buf, len) < 0)
242 yaz_log(YLOG_WARN, "Failed to decode MARC %s", db->url);
246 yaz_marc_write_using_libxml2(sdb->yaz_marc, 1);
247 if (yaz_marc_write_xml(sdb->yaz_marc, &res,
248 "http://www.loc.gov/MARC21/slim", 0, 0) < 0)
250 yaz_log(YLOG_WARN, "Failed to encode as XML %s",
254 rdoc = xmlNewDoc((xmlChar *) "1.0");
255 xmlDocSetRootElement(rdoc, res);
261 "Unknown native_syntax in normalize_record from %s",
266 if (global_parameters.dump_records){
268 "Input Record (normalized) from %s\n----------------\n",
270 #if LIBXML_VERSION >= 20600
271 xmlDocFormatDump(stderr, rdoc, 1);
273 xmlDocDump(stderr, rdoc);
277 for (m = sdb->map; m; m = m->next){
283 new = xsltApplyStylesheet(m->stylesheet, rdoc, 0);
284 root= xmlDocGetRootElement(new);
285 if (!new || !root || !(root->children))
287 yaz_log(YLOG_WARN, "XSLT transformation failed from %s",
297 // do it another way to detect transformation errors right now
298 // but does not seem to work either!
300 xsltTransformContextPtr ctxt;
301 ctxt = xsltNewTransformContext(m->stylesheet, rdoc);
302 new = xsltApplyStylesheetUser(m->stylesheet, rdoc, 0, 0, 0, ctxt);
303 if ((ctxt->state == XSLT_STATE_ERROR) ||
304 (ctxt->state == XSLT_STATE_STOPPED)){
305 yaz_log(YLOG_WARN, "XSLT transformation failed from %s",
306 cl->database->database->url);
317 if (global_parameters.dump_records)
319 fprintf(stderr, "Record from %s\n----------------\n",
321 #if LIBXML_VERSION >= 20600
322 xmlDocFormatDump(stderr, rdoc, 1);
324 xmlDocDump(stderr, rdoc);
330 // Retrieve first defined value for 'name' for given database.
331 // Will be extended to take into account user associated with session
332 char *session_setting_oneval(struct session_database *db, int offset)
334 if (!db->settings[offset])
336 return db->settings[offset]->value;
341 // Initialize YAZ Map structures for MARC-based targets
342 static int prepare_yazmarc(struct session_database *sdb)
348 yaz_log(YLOG_WARN, "No settings for %s", sdb->database->url);
351 if ((s = session_setting_oneval(sdb, PZ_NATIVESYNTAX))
352 && !strncmp(s, "iso2709", 7))
354 char *encoding = "marc-8s", *e;
357 // See if a native encoding is specified
358 if ((e = strchr(s, ';')))
361 sdb->yaz_marc = yaz_marc_create();
362 yaz_marc_subfield_str(sdb->yaz_marc, "\t");
364 cm = yaz_iconv_open("utf-8", encoding);
368 "Unable to map from %s to UTF-8 for target %s",
369 encoding, sdb->database->url);
372 yaz_marc_iconv(sdb->yaz_marc, cm);
377 // Prepare XSLT stylesheets for record normalization
378 // Structures are allocated on the session_wide nmem to avoid having
379 // to recompute this for every search. This would lead
380 // to leaking if a single session was to repeatedly change the PZ_XSLT
381 // setting. However, this is not a realistic use scenario.
382 static int prepare_map(struct session *se, struct session_database *sdb)
388 yaz_log(YLOG_WARN, "No settings on %s", sdb->database->url);
391 if ((s = session_setting_oneval(sdb, PZ_XSLT)))
394 struct database_retrievalmap **m = &sdb->map;
397 nmem_strsplit(se->session_nmem, ",", s, &stylesheets, &num);
398 for (i = 0; i < num; i++)
400 (*m) = nmem_malloc(se->session_nmem, sizeof(**m));
402 if (!((*m)->stylesheet = conf_load_stylesheet(stylesheets[i])))
404 yaz_log(YLOG_FATAL, "Unable to load stylesheet: %s",
412 yaz_log(YLOG_WARN, "No Normalization stylesheet for target %s",
417 // This analyzes settings and recomputes any supporting data structures
419 static int prepare_session_database(struct session *se,
420 struct session_database *sdb)
425 "No settings associated with %s", sdb->database->url);
428 if (sdb->settings[PZ_NATIVESYNTAX] && !sdb->yaz_marc)
430 if (prepare_yazmarc(sdb) < 0)
433 if (sdb->settings[PZ_XSLT] && !sdb->map)
435 if (prepare_map(se, sdb) < 0)
442 void session_set_watch(struct session *s, int what,
443 session_watchfun fun, void *data)
445 s->watchlist[what].fun = fun;
446 s->watchlist[what].data = data;
449 void session_alert_watch(struct session *s, int what)
451 if (!s->watchlist[what].fun)
453 (*s->watchlist[what].fun)(s->watchlist[what].data);
454 s->watchlist[what].fun = 0;
455 s->watchlist[what].data = 0;
458 //callback for grep_databases
459 static void select_targets_callback(void *context, struct session_database *db)
461 struct session *se = (struct session*) context;
462 struct client *cl = client_create();
463 client_set_database(cl, db);
464 client_set_session(cl, se);
467 // Associates a set of clients with a session;
468 // Note: Session-databases represent databases with per-session
470 int select_targets(struct session *se, struct database_criterion *crit)
473 client_destroy(se->clients);
475 return session_grep_databases(se, crit, select_targets_callback);
478 int session_active_clients(struct session *s)
483 for (c = s->clients; c; c = client_next_in_session(c))
484 if (client_is_active(c))
490 // parses crit1=val1,crit2=val2|val3,...
491 static struct database_criterion *parse_filter(NMEM m, const char *buf)
493 struct database_criterion *res = 0;
500 nmem_strsplit(m, ",", buf, &values, &num);
501 for (i = 0; i < num; i++)
506 struct database_criterion *new = nmem_malloc(m, sizeof(*new));
507 char *eq = strchr(values[i], '=');
510 yaz_log(YLOG_WARN, "Missing equal-sign in filter");
514 new->name = values[i];
515 nmem_strsplit(m, "|", eq, &subvalues, &subnum);
517 for (subi = 0; subi < subnum; subi++)
519 struct database_criterion_value *newv
520 = nmem_malloc(m, sizeof(*newv));
521 newv->value = subvalues[subi];
522 newv->next = new->values;
531 char *search(struct session *se, char *query, char *filter)
533 int live_channels = 0;
535 struct database_criterion *criteria;
537 yaz_log(YLOG_DEBUG, "Search");
539 nmem_reset(se->nmem);
540 criteria = parse_filter(se->nmem, filter);
542 live_channels = select_targets(se, criteria);
545 int maxrecs = live_channels * global_parameters.toget;
546 se->num_termlists = 0;
547 se->reclist = reclist_create(se->nmem, maxrecs);
548 // This will be initialized in send_search()
549 se->total_records = se->total_hits = se->total_merged = 0;
550 se->expected_maxrecs = maxrecs;
557 for (cl = se->clients; cl; cl = client_next_in_session(cl))
559 if (prepare_session_database(se, client_get_database(cl)) < 0)
560 return "CONFIG_ERROR";
561 // Query must parse for all targets
562 if (client_parse_query(cl, query) < 0)
566 for (cl = se->clients; cl; cl = client_next_in_session(cl))
568 client_prep_connection(cl);
574 // Creates a new session_database object for a database
575 static void session_init_databases_fun(void *context, struct database *db)
577 struct session *se = (struct session *) context;
578 struct session_database *new = nmem_malloc(se->session_nmem, sizeof(*new));
579 int num = settings_num();
586 = nmem_malloc(se->session_nmem, sizeof(struct settings *) * num);
587 memset(new->settings, 0, sizeof(struct settings*) * num);
591 for (i = 0; i < num; i++)
592 new->settings[i] = db->settings[i];
594 new->next = se->databases;
598 // Doesn't free memory associated with sdb -- nmem takes care of that
599 static void session_database_destroy(struct session_database *sdb)
601 struct database_retrievalmap *m;
603 for (m = sdb->map; m; m = m->next)
604 xsltFreeStylesheet(m->stylesheet);
606 yaz_marc_destroy(sdb->yaz_marc);
609 // Initialize session_database list -- this represents this session's view
610 // of the database list -- subject to modification by the settings ws command
611 void session_init_databases(struct session *se)
614 grep_databases(se, 0, session_init_databases_fun);
617 // Probably session_init_databases_fun should be refactored instead of
619 static struct session_database *load_session_database(struct session *se,
622 struct database *db = find_database(id, 0);
624 session_init_databases_fun((void*) se, db);
625 // New sdb is head of se->databases list
626 return se->databases;
629 // Find an existing session database. If not found, load it
630 static struct session_database *find_session_database(struct session *se,
633 struct session_database *sdb;
635 for (sdb = se->databases; sdb; sdb = sdb->next)
636 if (!strcmp(sdb->database->url, id))
638 return load_session_database(se, id);
641 // Apply a session override to a database
642 void session_apply_setting(struct session *se, char *dbname, char *setting,
645 struct session_database *sdb = find_session_database(se, dbname);
646 struct setting *new = nmem_malloc(se->session_nmem, sizeof(*new));
647 int offset = settings_offset(setting);
651 yaz_log(YLOG_WARN, "Unknown setting %s", setting);
655 new->target = dbname;
658 new->next = sdb->settings[offset];
659 sdb->settings[offset] = new;
661 // Force later recompute of settings-driven data structures
662 // (happens when a search starts and client connections are prepared)
665 case PZ_NATIVESYNTAX:
668 yaz_marc_destroy(sdb->yaz_marc);
675 struct database_retrievalmap *m;
676 // We don't worry about the map structure -- it's in nmem
677 for (m = sdb->map; m; m = m->next)
678 xsltFreeStylesheet(m->stylesheet);
685 void destroy_session(struct session *s)
687 struct session_database *sdb;
689 yaz_log(YLOG_LOG, "Destroying session");
691 client_destroy(s->clients);
692 for (sdb = s->databases; sdb; sdb = sdb->next)
693 session_database_destroy(sdb);
694 nmem_destroy(s->nmem);
695 wrbuf_destroy(s->wrbuf);
698 struct session *new_session(NMEM nmem)
701 struct session *session = nmem_malloc(nmem, sizeof(*session));
703 yaz_log(YLOG_DEBUG, "New Pazpar2 session");
705 session->total_hits = 0;
706 session->total_records = 0;
707 session->num_termlists = 0;
708 session->reclist = 0;
709 session->requestid = -1;
710 session->clients = 0;
711 session->expected_maxrecs = 0;
712 session->session_nmem = nmem;
713 session->nmem = nmem_create();
714 session->wrbuf = wrbuf_alloc();
715 session_init_databases(session);
716 for (i = 0; i <= SESSION_WATCH_MAX; i++)
718 session->watchlist[i].data = 0;
719 session->watchlist[i].fun = 0;
725 struct hitsbytarget *hitsbytarget(struct session *se, int *count)
727 static struct hitsbytarget res[1000]; // FIXME MM
731 for (cl = se->clients; cl; cl = client_next_in_session(cl))
733 char *name = session_setting_oneval(client_get_database(cl), PZ_NAME);
735 res[*count].id = client_get_database(cl)->database->url;
736 res[*count].name = *name ? name : "Unknown";
737 res[*count].hits = client_get_hits(cl);
738 res[*count].records = client_get_num_records(cl);
739 res[*count].diagnostic = client_get_diagnostic(cl);
740 res[*count].state = client_get_state_str(cl);
741 res[*count].connected = client_get_connection(cl) ? 1 : 0;
748 struct termlist_score **termlist(struct session *s, const char *name, int *num)
752 for (i = 0; i < s->num_termlists; i++)
753 if (!strcmp((const char *) s->termlists[i].name, name))
754 return termlist_highscore(s->termlists[i].termlist, num);
758 #ifdef MISSING_HEADERS
759 void report_nmem_stats(void)
761 size_t in_use, is_free;
763 nmem_get_memory_in_use(&in_use);
764 nmem_get_memory_free(&is_free);
766 yaz_log(YLOG_LOG, "nmem stat: use=%ld free=%ld",
767 (long) in_use, (long) is_free);
771 struct record_cluster *show_single(struct session *s, int id)
773 struct record_cluster *r;
775 reclist_rewind(s->reclist);
776 while ((r = reclist_read_record(s->reclist)))
782 struct record_cluster **show(struct session *s, struct reclist_sortparms *sp,
783 int start, int *num, int *total, int *sumhits,
786 struct record_cluster **recs = nmem_malloc(nmem_show, *num
787 * sizeof(struct record_cluster *));
788 struct reclist_sortparms *spp;
791 yaz_timing_t t = yaz_timing_create();
794 for (spp = sp; spp; spp = spp->next)
795 if (spp->type == Metadata_sortkey_relevance)
797 relevance_prepare_read(s->relevance, s->reclist);
800 reclist_sort(s->reclist, sp);
802 *total = s->reclist->num_records;
803 *sumhits = s->total_hits;
805 for (i = 0; i < start; i++)
806 if (!reclist_read_record(s->reclist))
813 for (i = 0; i < *num; i++)
815 struct record_cluster *r = reclist_read_record(s->reclist);
825 yaz_log(YLOG_LOG, "show %6.5f %3.2f %3.2f",
826 yaz_timing_get_real(t), yaz_timing_get_user(t),
827 yaz_timing_get_sys(t));
828 yaz_timing_destroy(&t);
833 void statistics(struct session *se, struct statistics *stat)
838 memset(stat, 0, sizeof(*stat));
839 for (cl = se->clients; cl; cl = client_next_in_session(cl))
841 if (!client_get_connection(cl))
842 stat->num_no_connection++;
843 switch (client_get_state(cl))
845 case Client_Connecting: stat->num_connecting++; break;
846 case Client_Initializing: stat->num_initializing++; break;
847 case Client_Searching: stat->num_searching++; break;
848 case Client_Presenting: stat->num_presenting++; break;
849 case Client_Idle: stat->num_idle++; break;
850 case Client_Failed: stat->num_failed++; break;
851 case Client_Error: stat->num_error++; break;
856 stat->num_hits = se->total_hits;
857 stat->num_records = se->total_records;
859 stat->num_clients = count;
862 void start_http_listener(void)
865 struct conf_server *ser = global_parameters.server;
867 if (*global_parameters.listener_override)
868 strcpy(hp, global_parameters.listener_override);
871 strcpy(hp, ser->host ? ser->host : "");
876 sprintf(hp + strlen(hp), "%d", ser->port);
882 void start_proxy(void)
885 struct conf_server *ser = global_parameters.server;
887 if (*global_parameters.proxy_override)
888 strcpy(hp, global_parameters.proxy_override);
889 else if (ser->proxy_host || ser->proxy_port)
891 strcpy(hp, ser->proxy_host ? ser->proxy_host : "");
896 sprintf(hp + strlen(hp), "%d", ser->proxy_port);
902 http_set_proxyaddr(hp, ser->myurl ? ser->myurl : "");
905 void start_zproxy(void)
907 struct conf_server *ser = global_parameters.server;
909 if (*global_parameters.zproxy_override){
910 yaz_log(YLOG_LOG, "Z39.50 proxy %s",
911 global_parameters.zproxy_override);
915 else if (ser->zproxy_host || ser->zproxy_port)
919 strcpy(hp, ser->zproxy_host ? ser->zproxy_host : "");
920 if (ser->zproxy_port)
927 sprintf(hp + strlen(hp), "%d", ser->zproxy_port);
929 strcpy(global_parameters.zproxy_override, hp);
930 yaz_log(YLOG_LOG, "Z39.50 proxy %s",
931 global_parameters.zproxy_override);
938 // Master list of connections we're handling events to
939 static IOCHAN channel_list = 0;
940 void pazpar2_add_channel(IOCHAN chan)
942 chan->next = channel_list;
946 void pazpar2_event_loop()
948 event_loop(&channel_list);
951 struct record *ingest_record(struct client *cl, Z_External *rec,
954 xmlDoc *xdoc = normalize_record(client_get_database(cl), rec);
957 struct record_cluster *cluster;
958 struct session *se = client_get_session(cl);
959 xmlChar *mergekey, *mergekey_norm;
962 struct conf_service *service = global_parameters.server->service;
967 root = xmlDocGetRootElement(xdoc);
968 if (!(mergekey = xmlGetProp(root, (xmlChar *) "mergekey")))
970 yaz_log(YLOG_WARN, "No mergekey found in record");
975 res = nmem_malloc(se->nmem, sizeof(struct record));
978 res->metadata = nmem_malloc(se->nmem,
979 sizeof(struct record_metadata*) * service->num_metadata);
980 memset(res->metadata, 0,
981 sizeof(struct record_metadata*) * service->num_metadata);
983 mergekey_norm = (xmlChar *) nmem_strdup(se->nmem, (char*) mergekey);
985 normalize_mergekey((char *) mergekey_norm, 0);
987 cluster = reclist_insert(se->reclist,
988 global_parameters.server->service,
989 res, (char *) mergekey_norm,
991 if (global_parameters.dump_records)
992 yaz_log(YLOG_LOG, "Cluster id %d from %s (#%d)", cluster->recid,
993 client_get_database(cl)->database->url, record_no);
996 /* no room for record */
1000 relevance_newrec(se->relevance, cluster);
1002 for (n = root->children; n; n = n->next)
1010 if (n->type != XML_ELEMENT_NODE)
1012 if (!strcmp((const char *) n->name, "metadata"))
1014 struct conf_metadata *ser_md = 0;
1015 struct conf_sortkey *ser_sk = 0;
1016 struct record_metadata **wheretoput, *newm;
1017 int md_field_id = -1;
1018 int sk_field_id = -1;
1021 type = xmlGetProp(n, (xmlChar *) "type");
1022 value = xmlNodeListGetString(xdoc, n->children, 0);
1024 if (!type || !value)
1027 // First, find out what field we're looking at
1028 for (md_field_id = 0; md_field_id < service->num_metadata;
1030 if (!strcmp((const char *) type,
1031 service->metadata[md_field_id].name))
1033 ser_md = &service->metadata[md_field_id];
1034 if (ser_md->sortkey_offset >= 0)
1035 ser_sk = &service->sortkeys[ser_md->sortkey_offset];
1041 "Ignoring unknown metadata element: %s", type);
1045 // Find out where we are putting it
1046 if (ser_md->merge == Metadata_merge_no)
1047 wheretoput = &res->metadata[md_field_id];
1049 wheretoput = &cluster->metadata[md_field_id];
1052 newm = nmem_malloc(se->nmem, sizeof(struct record_metadata));
1054 if (ser_md->type == Metadata_type_generic)
1057 for (p = (char *) value; *p && isspace(*p); p++)
1059 for (pe = p + strlen(p) - 1;
1060 pe > p && strchr(" ,/.:([", *pe); pe--)
1062 newm->data.text = nmem_strdup(se->nmem, p);
1065 else if (ser_md->type == Metadata_type_year)
1067 if (extract_years((char *) value, &first, &last) < 0)
1073 "Unknown type in metadata element %s", type);
1076 if (ser_md->type == Metadata_type_year
1077 && ser_md->merge != Metadata_merge_range)
1079 yaz_log(YLOG_WARN, "Only range merging supported for years");
1082 if (ser_md->merge == Metadata_merge_unique)
1084 struct record_metadata *mnode;
1085 for (mnode = *wheretoput; mnode; mnode = mnode->next)
1086 if (!strcmp((const char *) mnode->data.text,
1091 newm->next = *wheretoput;
1095 else if (ser_md->merge == Metadata_merge_longest)
1098 || strlen(newm->data.text)
1099 > strlen((*wheretoput)->data.text))
1104 char *s = nmem_strdup(se->nmem, newm->data.text);
1105 if (!cluster->sortkeys[ser_md->sortkey_offset])
1106 cluster->sortkeys[ser_md->sortkey_offset] =
1107 nmem_malloc(se->nmem,
1108 sizeof(union data_types));
1109 normalize_mergekey(s,
1110 (ser_sk->type == Metadata_sortkey_skiparticle));
1111 cluster->sortkeys[ser_md->sortkey_offset]->text = s;
1115 else if (ser_md->merge == Metadata_merge_all
1116 || ser_md->merge == Metadata_merge_no)
1118 newm->next = *wheretoput;
1121 else if (ser_md->merge == Metadata_merge_range)
1123 assert(ser_md->type == Metadata_type_year);
1127 (*wheretoput)->data.number.min = first;
1128 (*wheretoput)->data.number.max = last;
1130 cluster->sortkeys[ser_md->sortkey_offset]
1135 if (first < (*wheretoput)->data.number.min)
1136 (*wheretoput)->data.number.min = first;
1137 if (last > (*wheretoput)->data.number.max)
1138 (*wheretoput)->data.number.max = last;
1143 union data_types *sdata
1144 = cluster->sortkeys[md->sortkey_offset];
1145 yaz_log(YLOG_LOG, "SK range: %d-%d",
1146 sdata->number.min, sdata->number.max);
1152 "Don't know how to merge on element name %s",
1156 relevance_countwords(se->relevance, cluster,
1157 (char *) value, ser_md->rank);
1158 if (ser_md->termlist)
1160 if (ser_md->type == Metadata_type_year)
1163 sprintf(year, "%d", last);
1164 add_facet(se, (char *) type, year);
1167 sprintf(year, "%d", first);
1168 add_facet(se, (char *) type, year);
1172 add_facet(se, (char *) type, (char *) value);
1180 "Unexpected element %s in internal record", n->name);
1189 relevance_donerecord(se->relevance, cluster);
1190 se->total_records++;
1200 * indent-tabs-mode: nil
1202 * vim: shiftwidth=4 tabstop=8 expandtab