1 /* $Id: logic.c,v 1.46 2007-06-19 10:16:15 adam 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 #include <yaz/oid_db.h>
56 #include <yaz/timing.h>
59 #include <netinet/in.h>
64 #include "termlists.h"
66 #include "relevance.h"
71 #include "normalize7bit.h"
73 #define TERMLIST_HIGH_SCORE 25
77 // Note: Some things in this structure will eventually move to configuration
78 struct parameters global_parameters =
99 // Recursively traverse query structure to extract terms.
100 void pull_terms(NMEM nmem, struct ccl_rpn_node *n, char **termlist, int *num)
112 pull_terms(nmem, n->u.p[0], termlist, num);
113 pull_terms(nmem, n->u.p[1], termlist, num);
116 nmem_strsplit(nmem, " ", n->u.t.term, &words, &numwords);
117 for (i = 0; i < numwords; i++)
118 termlist[(*num)++] = words[i];
127 static void add_facet(struct session *s, const char *type, const char *value)
133 for (i = 0; i < s->num_termlists; i++)
134 if (!strcmp(s->termlists[i].name, type))
136 if (i == s->num_termlists)
138 if (i == SESSION_MAX_TERMLISTS)
140 yaz_log(YLOG_FATAL, "Too many termlists");
144 s->termlists[i].name = nmem_strdup(s->nmem, type);
145 s->termlists[i].termlist
146 = termlist_create(s->nmem, s->expected_maxrecs,
147 TERMLIST_HIGH_SCORE);
148 s->num_termlists = i + 1;
150 termlist_insert(s->termlists[i].termlist, value);
153 xmlDoc *record_to_xml(struct session_database *sdb, Z_External *rec)
155 struct database *db = sdb->database;
157 const Odr_oid *oid = rec->direct_reference;
159 /* convert response record to XML somehow */
160 if (rec->which == Z_External_octet && oid
161 && !oid_oidcmp(oid, yaz_oid_recsyn_xml))
164 rdoc = xmlParseMemory((char*) rec->u.octet_aligned->buf,
165 rec->u.octet_aligned->len);
168 yaz_log(YLOG_FATAL, "Non-wellformed XML received from %s",
173 else if (oid && yaz_oid_is_iso2709(oid))
175 /* ISO2709 gets converted to MARCXML */
178 yaz_log(YLOG_FATAL, "Unable to handle ISO2709 record");
187 if (rec->which != Z_External_octet)
189 yaz_log(YLOG_WARN, "Unexpected external branch, probably BER %s",
193 buf = (char*) rec->u.octet_aligned->buf;
194 len = rec->u.octet_aligned->len;
195 if (yaz_marc_read_iso2709(sdb->yaz_marc, buf, len) < 0)
197 yaz_log(YLOG_WARN, "Failed to decode MARC %s", db->url);
201 yaz_marc_write_using_libxml2(sdb->yaz_marc, 1);
202 if (yaz_marc_write_xml(sdb->yaz_marc, &res,
203 "http://www.loc.gov/MARC21/slim", 0, 0) < 0)
205 yaz_log(YLOG_WARN, "Failed to encode as XML %s",
209 rdoc = xmlNewDoc((xmlChar *) "1.0");
210 xmlDocSetRootElement(rdoc, res);
215 char oid_name_buf[OID_STR_MAX];
216 const char *oid_name = yaz_oid_to_string_buf(oid, 0, oid_name_buf);
218 "Unable to handle record of type %s from %s",
223 if (global_parameters.dump_records){
225 "Input Record (normalized) from %s\n----------------\n",
227 #if LIBXML_VERSION >= 20600
228 xmlDocFormatDump(stderr, rdoc, 1);
230 xmlDocDump(stderr, rdoc);
236 xmlDoc *normalize_record(struct session_database *sdb, Z_External *rec)
238 struct database_retrievalmap *m;
239 xmlDoc *rdoc = record_to_xml(sdb, rec);
242 for (m = sdb->map; m; m = m->next){
247 new = xsltApplyStylesheet(m->stylesheet, rdoc, 0);
248 root= xmlDocGetRootElement(new);
249 if (!new || !root || !(root->children))
251 yaz_log(YLOG_WARN, "XSLT transformation failed from %s",
262 if (global_parameters.dump_records)
264 fprintf(stderr, "Record from %s\n----------------\n",
266 #if LIBXML_VERSION >= 20600
267 xmlDocFormatDump(stderr, rdoc, 1);
269 xmlDocDump(stderr, rdoc);
276 // Retrieve first defined value for 'name' for given database.
277 // Will be extended to take into account user associated with session
278 char *session_setting_oneval(struct session_database *db, int offset)
280 if (!db->settings[offset])
282 return db->settings[offset]->value;
287 // Initialize YAZ Map structures for MARC-based targets
288 static int prepare_yazmarc(struct session_database *sdb)
294 yaz_log(YLOG_WARN, "No settings for %s", sdb->database->url);
297 if ((s = session_setting_oneval(sdb, PZ_NATIVESYNTAX))
298 && !strncmp(s, "iso2709", 7))
300 char *encoding = "marc-8s", *e;
303 // See if a native encoding is specified
304 if ((e = strchr(s, ';')))
307 sdb->yaz_marc = yaz_marc_create();
308 yaz_marc_subfield_str(sdb->yaz_marc, "\t");
310 cm = yaz_iconv_open("utf-8", encoding);
314 "Unable to map from %s to UTF-8 for target %s",
315 encoding, sdb->database->url);
318 yaz_marc_iconv(sdb->yaz_marc, cm);
323 // Prepare XSLT stylesheets for record normalization
324 // Structures are allocated on the session_wide nmem to avoid having
325 // to recompute this for every search. This would lead
326 // to leaking if a single session was to repeatedly change the PZ_XSLT
327 // setting. However, this is not a realistic use scenario.
328 static int prepare_map(struct session *se, struct session_database *sdb)
334 yaz_log(YLOG_WARN, "No settings on %s", sdb->database->url);
337 if ((s = session_setting_oneval(sdb, PZ_XSLT)))
340 struct database_retrievalmap **m = &sdb->map;
343 nmem_strsplit(se->session_nmem, ",", s, &stylesheets, &num);
344 for (i = 0; i < num; i++)
346 (*m) = nmem_malloc(se->session_nmem, sizeof(**m));
348 if (!((*m)->stylesheet = conf_load_stylesheet(stylesheets[i])))
350 yaz_log(YLOG_FATAL|YLOG_ERRNO, "Unable to load stylesheet: %s",
358 yaz_log(YLOG_WARN, "No Normalization stylesheet for target %s",
363 // This analyzes settings and recomputes any supporting data structures
365 static int prepare_session_database(struct session *se,
366 struct session_database *sdb)
371 "No settings associated with %s", sdb->database->url);
374 if (sdb->settings[PZ_NATIVESYNTAX] && !sdb->yaz_marc)
376 if (prepare_yazmarc(sdb) < 0)
379 if (sdb->settings[PZ_XSLT] && !sdb->map)
381 if (prepare_map(se, sdb) < 0)
387 // called if watch should be removed because http_channel is to be destroyed
388 static void session_watch_cancel(void *data, struct http_channel *c)
390 struct session_watchentry *ent = data;
397 // set watch. Returns 0=OK, -1 if watch is already set
398 int session_set_watch(struct session *s, int what,
399 session_watchfun fun, void *data,
400 struct http_channel *chan)
402 if (s->watchlist[what].fun)
404 s->watchlist[what].fun = fun;
405 s->watchlist[what].data = data;
406 s->watchlist[what].obs = http_add_observer(chan, &s->watchlist[what],
407 session_watch_cancel);
411 void session_alert_watch(struct session *s, int what)
413 if (!s->watchlist[what].fun)
415 http_remove_observer(s->watchlist[what].obs);
416 (*s->watchlist[what].fun)(s->watchlist[what].data);
417 s->watchlist[what].fun = 0;
418 s->watchlist[what].data = 0;
419 s->watchlist[what].obs = 0;
422 //callback for grep_databases
423 static void select_targets_callback(void *context, struct session_database *db)
425 struct session *se = (struct session*) context;
426 struct client *cl = client_create();
427 client_set_database(cl, db);
428 client_set_session(cl, se);
431 // Associates a set of clients with a session;
432 // Note: Session-databases represent databases with per-session
434 int select_targets(struct session *se, struct database_criterion *crit)
437 client_destroy(se->clients);
439 return session_grep_databases(se, crit, select_targets_callback);
442 int session_active_clients(struct session *s)
447 for (c = s->clients; c; c = client_next_in_session(c))
448 if (client_is_active(c))
454 // parses crit1=val1,crit2=val2|val3,...
455 static struct database_criterion *parse_filter(NMEM m, const char *buf)
457 struct database_criterion *res = 0;
464 nmem_strsplit(m, ",", buf, &values, &num);
465 for (i = 0; i < num; i++)
470 struct database_criterion *new = nmem_malloc(m, sizeof(*new));
471 char *eq = strchr(values[i], '=');
474 yaz_log(YLOG_WARN, "Missing equal-sign in filter");
478 new->name = values[i];
479 nmem_strsplit(m, "|", eq, &subvalues, &subnum);
481 for (subi = 0; subi < subnum; subi++)
483 struct database_criterion_value *newv
484 = nmem_malloc(m, sizeof(*newv));
485 newv->value = subvalues[subi];
486 newv->next = new->values;
495 enum pazpar2_error_code search(struct session *se,
496 char *query, char *filter,
497 const char **addinfo)
499 int live_channels = 0;
501 struct database_criterion *criteria;
503 yaz_log(YLOG_DEBUG, "Search");
506 nmem_reset(se->nmem);
507 criteria = parse_filter(se->nmem, filter);
509 live_channels = select_targets(se, criteria);
512 int maxrecs = live_channels * global_parameters.toget;
513 se->num_termlists = 0;
514 se->reclist = reclist_create(se->nmem, maxrecs);
515 // This will be initialized in send_search()
516 se->total_records = se->total_hits = se->total_merged = 0;
517 se->expected_maxrecs = maxrecs;
520 return PAZPAR2_NO_TARGETS;
524 for (cl = se->clients; cl; cl = client_next_in_session(cl))
526 if (prepare_session_database(se, client_get_database(cl)) < 0)
528 *addinfo = client_get_database(cl)->database->url;
529 return PAZPAR2_CONFIG_TARGET;
531 // Query must parse for all targets
532 if (client_parse_query(cl, query) < 0)
535 return PAZPAR2_MALFORMED_PARAMETER_VALUE;
539 for (cl = se->clients; cl; cl = client_next_in_session(cl))
540 client_prep_connection(cl);
542 return PAZPAR2_NO_ERROR;
545 // Creates a new session_database object for a database
546 static void session_init_databases_fun(void *context, struct database *db)
548 struct session *se = (struct session *) context;
549 struct session_database *new = nmem_malloc(se->session_nmem, sizeof(*new));
550 int num = settings_num();
557 if (global_parameters.server && global_parameters.server->icu_chn)
558 new->pct = pp2_charset_create(global_parameters.server->icu_chn);
560 new->pct = pp2_charset_create(0);
562 new->pct = pp2_charset_create(0);
567 = nmem_malloc(se->session_nmem, sizeof(struct settings *) * num);
568 memset(new->settings, 0, sizeof(struct settings*) * num);
572 for (i = 0; i < num; i++)
573 new->settings[i] = db->settings[i];
575 new->next = se->databases;
579 // Doesn't free memory associated with sdb -- nmem takes care of that
580 static void session_database_destroy(struct session_database *sdb)
582 struct database_retrievalmap *m;
584 for (m = sdb->map; m; m = m->next)
585 xsltFreeStylesheet(m->stylesheet);
587 yaz_marc_destroy(sdb->yaz_marc);
589 pp2_charset_destroy(sdb->pct);
592 // Initialize session_database list -- this represents this session's view
593 // of the database list -- subject to modification by the settings ws command
594 void session_init_databases(struct session *se)
597 grep_databases(se, 0, session_init_databases_fun);
600 // Probably session_init_databases_fun should be refactored instead of
602 static struct session_database *load_session_database(struct session *se,
605 struct database *db = find_database(id, 0);
607 session_init_databases_fun((void*) se, db);
608 // New sdb is head of se->databases list
609 return se->databases;
612 // Find an existing session database. If not found, load it
613 static struct session_database *find_session_database(struct session *se,
616 struct session_database *sdb;
618 for (sdb = se->databases; sdb; sdb = sdb->next)
619 if (!strcmp(sdb->database->url, id))
621 return load_session_database(se, id);
624 // Apply a session override to a database
625 void session_apply_setting(struct session *se, char *dbname, char *setting,
628 struct session_database *sdb = find_session_database(se, dbname);
629 struct setting *new = nmem_malloc(se->session_nmem, sizeof(*new));
630 int offset = settings_offset_cprefix(setting);
634 yaz_log(YLOG_WARN, "Unknown setting %s", setting);
637 // Jakub: This breaks the filter setting.
638 /*if (offset == PZ_ID)
640 yaz_log(YLOG_WARN, "No need to set pz:id setting. Ignoring");
644 new->target = dbname;
647 new->next = sdb->settings[offset];
648 sdb->settings[offset] = new;
650 // Force later recompute of settings-driven data structures
651 // (happens when a search starts and client connections are prepared)
654 case PZ_NATIVESYNTAX:
657 yaz_marc_destroy(sdb->yaz_marc);
664 struct database_retrievalmap *m;
665 // We don't worry about the map structure -- it's in nmem
666 for (m = sdb->map; m; m = m->next)
667 xsltFreeStylesheet(m->stylesheet);
674 void destroy_session(struct session *s)
676 struct session_database *sdb;
679 client_destroy(s->clients);
680 for (sdb = s->databases; sdb; sdb = sdb->next)
681 session_database_destroy(sdb);
682 nmem_destroy(s->nmem);
683 wrbuf_destroy(s->wrbuf);
686 struct session *new_session(NMEM nmem)
689 struct session *session = nmem_malloc(nmem, sizeof(*session));
691 yaz_log(YLOG_DEBUG, "New Pazpar2 session");
693 session->relevance = 0;
694 session->total_hits = 0;
695 session->total_records = 0;
696 session->num_termlists = 0;
697 session->reclist = 0;
698 session->requestid = -1;
699 session->clients = 0;
700 session->expected_maxrecs = 0;
701 session->session_nmem = nmem;
702 session->nmem = nmem_create();
703 session->wrbuf = wrbuf_alloc();
704 session_init_databases(session);
705 for (i = 0; i <= SESSION_WATCH_MAX; i++)
707 session->watchlist[i].data = 0;
708 session->watchlist[i].fun = 0;
714 struct hitsbytarget *hitsbytarget(struct session *se, int *count)
716 static struct hitsbytarget res[1000]; // FIXME MM
720 for (cl = se->clients; cl; cl = client_next_in_session(cl))
722 char *name = session_setting_oneval(client_get_database(cl), PZ_NAME);
724 res[*count].id = client_get_database(cl)->database->url;
725 res[*count].name = *name ? name : "Unknown";
726 res[*count].hits = client_get_hits(cl);
727 res[*count].records = client_get_num_records(cl);
728 res[*count].diagnostic = client_get_diagnostic(cl);
729 res[*count].state = client_get_state_str(cl);
730 res[*count].connected = client_get_connection(cl) ? 1 : 0;
737 struct termlist_score **termlist(struct session *s, const char *name, int *num)
741 for (i = 0; i < s->num_termlists; i++)
742 if (!strcmp((const char *) s->termlists[i].name, name))
743 return termlist_highscore(s->termlists[i].termlist, num);
747 #ifdef MISSING_HEADERS
748 void report_nmem_stats(void)
750 size_t in_use, is_free;
752 nmem_get_memory_in_use(&in_use);
753 nmem_get_memory_free(&is_free);
755 yaz_log(YLOG_LOG, "nmem stat: use=%ld free=%ld",
756 (long) in_use, (long) is_free);
760 struct record_cluster *show_single(struct session *s, int id)
762 struct record_cluster *r;
764 reclist_rewind(s->reclist);
765 while ((r = reclist_read_record(s->reclist)))
771 struct record_cluster **show(struct session *s, struct reclist_sortparms *sp,
772 int start, int *num, int *total, int *sumhits,
775 struct record_cluster **recs = nmem_malloc(nmem_show, *num
776 * sizeof(struct record_cluster *));
777 struct reclist_sortparms *spp;
780 yaz_timing_t t = yaz_timing_create();
792 for (spp = sp; spp; spp = spp->next)
793 if (spp->type == Metadata_sortkey_relevance)
795 relevance_prepare_read(s->relevance, s->reclist);
798 reclist_sort(s->reclist, sp);
800 *total = s->reclist->num_records;
801 *sumhits = s->total_hits;
803 for (i = 0; i < start; i++)
804 if (!reclist_read_record(s->reclist))
811 for (i = 0; i < *num; i++)
813 struct record_cluster *r = reclist_read_record(s->reclist);
824 yaz_log(YLOG_LOG, "show %6.5f %3.2f %3.2f",
825 yaz_timing_get_real(t), yaz_timing_get_user(t),
826 yaz_timing_get_sys(t));
827 yaz_timing_destroy(&t);
832 void statistics(struct session *se, struct statistics *stat)
837 memset(stat, 0, sizeof(*stat));
838 for (cl = se->clients; cl; cl = client_next_in_session(cl))
840 if (!client_get_connection(cl))
841 stat->num_no_connection++;
842 switch (client_get_state(cl))
844 case Client_Connecting: stat->num_connecting++; break;
845 case Client_Initializing: stat->num_initializing++; break;
846 case Client_Searching: stat->num_searching++; break;
847 case Client_Presenting: stat->num_presenting++; break;
848 case Client_Idle: stat->num_idle++; break;
849 case Client_Failed: stat->num_failed++; break;
850 case Client_Error: stat->num_error++; break;
855 stat->num_hits = se->total_hits;
856 stat->num_records = se->total_records;
858 stat->num_clients = count;
861 void start_http_listener(void)
864 struct conf_server *ser = global_parameters.server;
866 if (*global_parameters.listener_override)
867 strcpy(hp, global_parameters.listener_override);
870 strcpy(hp, ser->host ? ser->host : "");
875 sprintf(hp + strlen(hp), "%d", ser->port);
881 void start_proxy(void)
884 struct conf_server *ser = global_parameters.server;
886 if (*global_parameters.proxy_override)
887 strcpy(hp, global_parameters.proxy_override);
888 else if (ser->proxy_host || ser->proxy_port)
890 strcpy(hp, ser->proxy_host ? ser->proxy_host : "");
895 sprintf(hp + strlen(hp), "%d", ser->proxy_port);
901 http_set_proxyaddr(hp, ser->myurl ? ser->myurl : "");
905 // Master list of connections we're handling events to
906 static IOCHAN channel_list = 0;
907 void pazpar2_add_channel(IOCHAN chan)
909 chan->next = channel_list;
913 void pazpar2_event_loop()
915 event_loop(&channel_list);
918 struct record *ingest_record(struct client *cl, Z_External *rec,
921 xmlDoc *xdoc = normalize_record(client_get_database(cl), rec);
923 struct record *record;
924 struct record_cluster *cluster;
925 struct session *se = client_get_session(cl);
926 xmlChar *mergekey, *mergekey_norm;
929 struct conf_service *service = global_parameters.server->service;
934 root = xmlDocGetRootElement(xdoc);
935 if (!(mergekey = xmlGetProp(root, (xmlChar *) "mergekey")))
937 yaz_log(YLOG_WARN, "No mergekey found in record");
942 record = record_create(se->nmem,
943 service->num_metadata, service->num_sortkeys, cl,
946 mergekey_norm = (xmlChar *) nmem_strdup(se->nmem, (char*) mergekey);
948 normalize7bit_mergekey((char *) mergekey_norm, 0);
950 cluster = reclist_insert(se->reclist,
951 global_parameters.server->service,
952 record, (char *) mergekey_norm,
954 if (global_parameters.dump_records)
955 yaz_log(YLOG_LOG, "Cluster id %d from %s (#%d)", cluster->recid,
956 client_get_database(cl)->database->url, record_no);
959 /* no room for record */
963 relevance_newrec(se->relevance, cluster);
966 // now parsing XML record and adding data to cluster or record metadata
967 for (n = root->children; n; n = n->next)
975 if (n->type != XML_ELEMENT_NODE)
977 if (!strcmp((const char *) n->name, "metadata"))
979 struct conf_metadata *ser_md = 0;
980 struct conf_sortkey *ser_sk = 0;
981 struct record_metadata **wheretoput = 0;
982 struct record_metadata *rec_md = 0;
983 int md_field_id = -1;
984 int sk_field_id = -1;
987 type = xmlGetProp(n, (xmlChar *) "type");
988 value = xmlNodeListGetString(xdoc, n->children, 1);
994 = conf_service_metadata_field_id(service, (const char *) type);
998 "Ignoring unknown metadata element: %s", type);
1002 ser_md = &service->metadata[md_field_id];
1004 if (ser_md->sortkey_offset >= 0){
1005 sk_field_id = ser_md->sortkey_offset;
1006 ser_sk = &service->sortkeys[sk_field_id];
1009 // Find out where we are putting it - based on merge or not
1010 if (ser_md->merge == Metadata_merge_no)
1011 wheretoput = &record->metadata[md_field_id];
1013 wheretoput = &cluster->metadata[md_field_id];
1015 // create new record_metadata
1016 rec_md = record_metadata_create(se->nmem);
1018 // and polulate with data:
1019 // type based charmapping decisions follow here
1020 if (ser_md->type == Metadata_type_generic)
1023 char * p = (char *) value;
1024 p = normalize7bit_generic(p, " ,/.:([");
1026 rec_md->data.text = nmem_strdup(se->nmem, p);
1029 else if (ser_md->type == Metadata_type_year)
1031 if (extract7bit_years((char *) value, &first, &last) < 0)
1037 "Unknown type in metadata element %s", type);
1041 // and polulate with data:
1042 // assign cluster or record based on merge action
1043 if (ser_md->merge == Metadata_merge_unique)
1045 struct record_metadata *mnode;
1046 for (mnode = *wheretoput; mnode; mnode = mnode->next)
1047 if (!strcmp((const char *) mnode->data.text,
1052 rec_md->next = *wheretoput;
1053 *wheretoput = rec_md;
1056 else if (ser_md->merge == Metadata_merge_longest)
1059 || strlen(rec_md->data.text)
1060 > strlen((*wheretoput)->data.text))
1062 *wheretoput = rec_md;
1065 char *s = nmem_strdup(se->nmem, rec_md->data.text);
1066 if (!cluster->sortkeys[sk_field_id])
1067 cluster->sortkeys[sk_field_id] =
1068 nmem_malloc(se->nmem,
1069 sizeof(union data_types));
1070 normalize7bit_mergekey(s,
1071 (ser_sk->type == Metadata_sortkey_skiparticle));
1072 cluster->sortkeys[sk_field_id]->text = s;
1076 else if (ser_md->merge == Metadata_merge_all
1077 || ser_md->merge == Metadata_merge_no)
1079 rec_md->next = *wheretoput;
1080 *wheretoput = rec_md;
1082 else if (ser_md->merge == Metadata_merge_range)
1086 *wheretoput = rec_md;
1087 (*wheretoput)->data.number.min = first;
1088 (*wheretoput)->data.number.max = last;
1090 cluster->sortkeys[sk_field_id]
1095 if (first < (*wheretoput)->data.number.min)
1096 (*wheretoput)->data.number.min = first;
1097 if (last > (*wheretoput)->data.number.max)
1098 (*wheretoput)->data.number.max = last;
1103 union data_types *sdata
1104 = cluster->sortkeys[sk_field_id];
1105 yaz_log(YLOG_LOG, "SK range: %d-%d",
1106 sdata->number.min, sdata->number.max);
1112 // ranking of _all_ fields enabled ...
1114 relevance_countwords(se->relevance, cluster,
1115 (char *) value, ser_md->rank);
1117 // construct facets ...
1118 if (ser_md->termlist)
1120 if (ser_md->type == Metadata_type_year)
1123 sprintf(year, "%d", last);
1124 add_facet(se, (char *) type, year);
1127 sprintf(year, "%d", first);
1128 add_facet(se, (char *) type, year);
1132 add_facet(se, (char *) type, (char *) value);
1142 "Unexpected element %s in internal record", n->name);
1151 relevance_donerecord(se->relevance, cluster);
1152 se->total_records++;
1162 * indent-tabs-mode: nil
1164 * vim: shiftwidth=4 tabstop=8 expandtab