1 /* $Id: logic.c,v 1.36 2007-06-06 11:49:48 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"
73 #include "normalize7bit.h"
77 // Note: Some things in this structure will eventually move to configuration
78 struct parameters global_parameters =
100 // Recursively traverse query structure to extract terms.
101 void pull_terms(NMEM nmem, struct ccl_rpn_node *n, char **termlist, int *num)
113 pull_terms(nmem, n->u.p[0], termlist, num);
114 pull_terms(nmem, n->u.p[1], termlist, num);
117 nmem_strsplit(nmem, " ", n->u.t.term, &words, &numwords);
118 for (i = 0; i < numwords; i++)
119 termlist[(*num)++] = words[i];
128 static void add_facet(struct session *s, const char *type, const char *value)
134 for (i = 0; i < s->num_termlists; i++)
135 if (!strcmp(s->termlists[i].name, type))
137 if (i == s->num_termlists)
139 if (i == SESSION_MAX_TERMLISTS)
141 yaz_log(YLOG_FATAL, "Too many termlists");
145 s->termlists[i].name = nmem_strdup(s->nmem, type);
146 s->termlists[i].termlist
147 = termlist_create(s->nmem, s->expected_maxrecs, 15);
148 s->num_termlists = i + 1;
150 termlist_insert(s->termlists[i].termlist, value);
153 xmlDoc *normalize_record(struct session_database *sdb, Z_External *rec)
155 struct database_retrievalmap *m;
156 struct database *db = sdb->database;
158 const Odr_oid *oid = rec->direct_reference;
160 /* convert response record to XML somehow */
161 if (rec->which == Z_External_octet && oid
162 && !oid_oidcmp(oid, yaz_oid_recsyn_xml))
165 rdoc = xmlParseMemory((char*) rec->u.octet_aligned->buf,
166 rec->u.octet_aligned->len);
169 yaz_log(YLOG_FATAL, "Non-wellformed XML received from %s",
174 else if (oid && yaz_oid_is_iso2709(oid))
176 /* ISO2709 gets converted to MARCXML */
179 yaz_log(YLOG_FATAL, "Unable to handle ISO2709 record");
188 if (rec->which != Z_External_octet)
190 yaz_log(YLOG_WARN, "Unexpected external branch, probably BER %s",
194 buf = (char*) rec->u.octet_aligned->buf;
195 len = rec->u.octet_aligned->len;
196 if (yaz_marc_read_iso2709(sdb->yaz_marc, buf, len) < 0)
198 yaz_log(YLOG_WARN, "Failed to decode MARC %s", db->url);
202 yaz_marc_write_using_libxml2(sdb->yaz_marc, 1);
203 if (yaz_marc_write_xml(sdb->yaz_marc, &res,
204 "http://www.loc.gov/MARC21/slim", 0, 0) < 0)
206 yaz_log(YLOG_WARN, "Failed to encode as XML %s",
210 rdoc = xmlNewDoc((xmlChar *) "1.0");
211 xmlDocSetRootElement(rdoc, res);
216 char oid_name_buf[OID_STR_MAX];
217 const char *oid_name = yaz_oid_to_string_buf(oid, 0, oid_name_buf);
219 "Unable to handle record of type %s from %s",
224 if (global_parameters.dump_records){
226 "Input Record (normalized) from %s\n----------------\n",
228 #if LIBXML_VERSION >= 20600
229 xmlDocFormatDump(stderr, rdoc, 1);
231 xmlDocDump(stderr, rdoc);
235 for (m = sdb->map; m; m = m->next){
240 new = xsltApplyStylesheet(m->stylesheet, rdoc, 0);
241 root= xmlDocGetRootElement(new);
242 if (!new || !root || !(root->children))
244 yaz_log(YLOG_WARN, "XSLT transformation failed from %s",
255 if (global_parameters.dump_records)
257 fprintf(stderr, "Record from %s\n----------------\n",
259 #if LIBXML_VERSION >= 20600
260 xmlDocFormatDump(stderr, rdoc, 1);
262 xmlDocDump(stderr, rdoc);
268 // Retrieve first defined value for 'name' for given database.
269 // Will be extended to take into account user associated with session
270 char *session_setting_oneval(struct session_database *db, int offset)
272 if (!db->settings[offset])
274 return db->settings[offset]->value;
279 // Initialize YAZ Map structures for MARC-based targets
280 static int prepare_yazmarc(struct session_database *sdb)
286 yaz_log(YLOG_WARN, "No settings for %s", sdb->database->url);
289 if ((s = session_setting_oneval(sdb, PZ_NATIVESYNTAX))
290 && !strncmp(s, "iso2709", 7))
292 char *encoding = "marc-8s", *e;
295 // See if a native encoding is specified
296 if ((e = strchr(s, ';')))
299 sdb->yaz_marc = yaz_marc_create();
300 yaz_marc_subfield_str(sdb->yaz_marc, "\t");
302 cm = yaz_iconv_open("utf-8", encoding);
306 "Unable to map from %s to UTF-8 for target %s",
307 encoding, sdb->database->url);
310 yaz_marc_iconv(sdb->yaz_marc, cm);
315 // Prepare XSLT stylesheets for record normalization
316 // Structures are allocated on the session_wide nmem to avoid having
317 // to recompute this for every search. This would lead
318 // to leaking if a single session was to repeatedly change the PZ_XSLT
319 // setting. However, this is not a realistic use scenario.
320 static int prepare_map(struct session *se, struct session_database *sdb)
326 yaz_log(YLOG_WARN, "No settings on %s", sdb->database->url);
329 if ((s = session_setting_oneval(sdb, PZ_XSLT)))
332 struct database_retrievalmap **m = &sdb->map;
335 nmem_strsplit(se->session_nmem, ",", s, &stylesheets, &num);
336 for (i = 0; i < num; i++)
338 (*m) = nmem_malloc(se->session_nmem, sizeof(**m));
340 if (!((*m)->stylesheet = conf_load_stylesheet(stylesheets[i])))
342 yaz_log(YLOG_FATAL, "Unable to load stylesheet: %s",
350 yaz_log(YLOG_WARN, "No Normalization stylesheet for target %s",
355 // This analyzes settings and recomputes any supporting data structures
357 static int prepare_session_database(struct session *se,
358 struct session_database *sdb)
363 "No settings associated with %s", sdb->database->url);
366 if (sdb->settings[PZ_NATIVESYNTAX] && !sdb->yaz_marc)
368 if (prepare_yazmarc(sdb) < 0)
371 if (sdb->settings[PZ_XSLT] && !sdb->map)
373 if (prepare_map(se, sdb) < 0)
380 void session_set_watch(struct session *s, int what,
381 session_watchfun fun, void *data)
383 s->watchlist[what].fun = fun;
384 s->watchlist[what].data = data;
387 void session_alert_watch(struct session *s, int what)
389 if (!s->watchlist[what].fun)
391 (*s->watchlist[what].fun)(s->watchlist[what].data);
392 s->watchlist[what].fun = 0;
393 s->watchlist[what].data = 0;
396 //callback for grep_databases
397 static void select_targets_callback(void *context, struct session_database *db)
399 struct session *se = (struct session*) context;
400 struct client *cl = client_create();
401 client_set_database(cl, db);
402 client_set_session(cl, se);
405 // Associates a set of clients with a session;
406 // Note: Session-databases represent databases with per-session
408 int select_targets(struct session *se, struct database_criterion *crit)
411 client_destroy(se->clients);
413 return session_grep_databases(se, crit, select_targets_callback);
416 int session_active_clients(struct session *s)
421 for (c = s->clients; c; c = client_next_in_session(c))
422 if (client_is_active(c))
428 // parses crit1=val1,crit2=val2|val3,...
429 static struct database_criterion *parse_filter(NMEM m, const char *buf)
431 struct database_criterion *res = 0;
438 nmem_strsplit(m, ",", buf, &values, &num);
439 for (i = 0; i < num; i++)
444 struct database_criterion *new = nmem_malloc(m, sizeof(*new));
445 char *eq = strchr(values[i], '=');
448 yaz_log(YLOG_WARN, "Missing equal-sign in filter");
452 new->name = values[i];
453 nmem_strsplit(m, "|", eq, &subvalues, &subnum);
455 for (subi = 0; subi < subnum; subi++)
457 struct database_criterion_value *newv
458 = nmem_malloc(m, sizeof(*newv));
459 newv->value = subvalues[subi];
460 newv->next = new->values;
469 char *search(struct session *se, char *query, char *filter)
471 int live_channels = 0;
473 struct database_criterion *criteria;
475 yaz_log(YLOG_DEBUG, "Search");
477 nmem_reset(se->nmem);
478 criteria = parse_filter(se->nmem, filter);
480 live_channels = select_targets(se, criteria);
483 int maxrecs = live_channels * global_parameters.toget;
484 se->num_termlists = 0;
485 se->reclist = reclist_create(se->nmem, maxrecs);
486 // This will be initialized in send_search()
487 se->total_records = se->total_hits = se->total_merged = 0;
488 se->expected_maxrecs = maxrecs;
495 for (cl = se->clients; cl; cl = client_next_in_session(cl))
497 if (prepare_session_database(se, client_get_database(cl)) < 0)
498 return "CONFIG_ERROR";
499 // Query must parse for all targets
500 if (client_parse_query(cl, query) < 0)
504 for (cl = se->clients; cl; cl = client_next_in_session(cl))
505 client_prep_connection(cl);
510 // Creates a new session_database object for a database
511 static void session_init_databases_fun(void *context, struct database *db)
513 struct session *se = (struct session *) context;
514 struct session_database *new = nmem_malloc(se->session_nmem, sizeof(*new));
515 int num = settings_num();
522 if (global_parameters.server && global_parameters.server->icu_chn)
523 new->pct = pp2_charset_create(global_parameters.server->icu_chn);
525 new->pct = pp2_charset_create(0);
527 new->pct = pp2_charset_create(0);
532 = nmem_malloc(se->session_nmem, sizeof(struct settings *) * num);
533 memset(new->settings, 0, sizeof(struct settings*) * num);
537 for (i = 0; i < num; i++)
538 new->settings[i] = db->settings[i];
540 new->next = se->databases;
544 // Doesn't free memory associated with sdb -- nmem takes care of that
545 static void session_database_destroy(struct session_database *sdb)
547 struct database_retrievalmap *m;
549 for (m = sdb->map; m; m = m->next)
550 xsltFreeStylesheet(m->stylesheet);
552 yaz_marc_destroy(sdb->yaz_marc);
554 pp2_charset_destroy(sdb->pct);
557 // Initialize session_database list -- this represents this session's view
558 // of the database list -- subject to modification by the settings ws command
559 void session_init_databases(struct session *se)
562 grep_databases(se, 0, session_init_databases_fun);
565 // Probably session_init_databases_fun should be refactored instead of
567 static struct session_database *load_session_database(struct session *se,
570 struct database *db = find_database(id, 0);
572 session_init_databases_fun((void*) se, db);
573 // New sdb is head of se->databases list
574 return se->databases;
577 // Find an existing session database. If not found, load it
578 static struct session_database *find_session_database(struct session *se,
581 struct session_database *sdb;
583 for (sdb = se->databases; sdb; sdb = sdb->next)
584 if (!strcmp(sdb->database->url, id))
586 return load_session_database(se, id);
589 // Apply a session override to a database
590 void session_apply_setting(struct session *se, char *dbname, char *setting,
593 struct session_database *sdb = find_session_database(se, dbname);
594 struct setting *new = nmem_malloc(se->session_nmem, sizeof(*new));
595 int offset = settings_offset_cprefix(setting);
599 yaz_log(YLOG_WARN, "Unknown setting %s", setting);
602 // Jakub: This breaks the filter setting.
603 /*if (offset == PZ_ID)
605 yaz_log(YLOG_WARN, "No need to set pz:id setting. Ignoring");
609 new->target = dbname;
612 new->next = sdb->settings[offset];
613 sdb->settings[offset] = new;
615 // Force later recompute of settings-driven data structures
616 // (happens when a search starts and client connections are prepared)
619 case PZ_NATIVESYNTAX:
622 yaz_marc_destroy(sdb->yaz_marc);
629 struct database_retrievalmap *m;
630 // We don't worry about the map structure -- it's in nmem
631 for (m = sdb->map; m; m = m->next)
632 xsltFreeStylesheet(m->stylesheet);
639 void destroy_session(struct session *s)
641 struct session_database *sdb;
643 yaz_log(YLOG_LOG, "Destroying session");
645 client_destroy(s->clients);
646 for (sdb = s->databases; sdb; sdb = sdb->next)
647 session_database_destroy(sdb);
648 nmem_destroy(s->nmem);
649 wrbuf_destroy(s->wrbuf);
652 struct session *new_session(NMEM nmem)
655 struct session *session = nmem_malloc(nmem, sizeof(*session));
657 yaz_log(YLOG_DEBUG, "New Pazpar2 session");
659 session->total_hits = 0;
660 session->total_records = 0;
661 session->num_termlists = 0;
662 session->reclist = 0;
663 session->requestid = -1;
664 session->clients = 0;
665 session->expected_maxrecs = 0;
666 session->session_nmem = nmem;
667 session->nmem = nmem_create();
668 session->wrbuf = wrbuf_alloc();
669 session_init_databases(session);
670 for (i = 0; i <= SESSION_WATCH_MAX; i++)
672 session->watchlist[i].data = 0;
673 session->watchlist[i].fun = 0;
679 struct hitsbytarget *hitsbytarget(struct session *se, int *count)
681 static struct hitsbytarget res[1000]; // FIXME MM
685 for (cl = se->clients; cl; cl = client_next_in_session(cl))
687 char *name = session_setting_oneval(client_get_database(cl), PZ_NAME);
689 res[*count].id = client_get_database(cl)->database->url;
690 res[*count].name = *name ? name : "Unknown";
691 res[*count].hits = client_get_hits(cl);
692 res[*count].records = client_get_num_records(cl);
693 res[*count].diagnostic = client_get_diagnostic(cl);
694 res[*count].state = client_get_state_str(cl);
695 res[*count].connected = client_get_connection(cl) ? 1 : 0;
702 struct termlist_score **termlist(struct session *s, const char *name, int *num)
706 for (i = 0; i < s->num_termlists; i++)
707 if (!strcmp((const char *) s->termlists[i].name, name))
708 return termlist_highscore(s->termlists[i].termlist, num);
712 #ifdef MISSING_HEADERS
713 void report_nmem_stats(void)
715 size_t in_use, is_free;
717 nmem_get_memory_in_use(&in_use);
718 nmem_get_memory_free(&is_free);
720 yaz_log(YLOG_LOG, "nmem stat: use=%ld free=%ld",
721 (long) in_use, (long) is_free);
725 struct record_cluster *show_single(struct session *s, int id)
727 struct record_cluster *r;
729 reclist_rewind(s->reclist);
730 while ((r = reclist_read_record(s->reclist)))
736 struct record_cluster **show(struct session *s, struct reclist_sortparms *sp,
737 int start, int *num, int *total, int *sumhits,
740 struct record_cluster **recs = nmem_malloc(nmem_show, *num
741 * sizeof(struct record_cluster *));
742 struct reclist_sortparms *spp;
745 yaz_timing_t t = yaz_timing_create();
748 for (spp = sp; spp; spp = spp->next)
749 if (spp->type == Metadata_sortkey_relevance)
751 relevance_prepare_read(s->relevance, s->reclist);
754 reclist_sort(s->reclist, sp);
756 *total = s->reclist->num_records;
757 *sumhits = s->total_hits;
759 for (i = 0; i < start; i++)
760 if (!reclist_read_record(s->reclist))
767 for (i = 0; i < *num; i++)
769 struct record_cluster *r = reclist_read_record(s->reclist);
779 yaz_log(YLOG_LOG, "show %6.5f %3.2f %3.2f",
780 yaz_timing_get_real(t), yaz_timing_get_user(t),
781 yaz_timing_get_sys(t));
782 yaz_timing_destroy(&t);
787 void statistics(struct session *se, struct statistics *stat)
792 memset(stat, 0, sizeof(*stat));
793 for (cl = se->clients; cl; cl = client_next_in_session(cl))
795 if (!client_get_connection(cl))
796 stat->num_no_connection++;
797 switch (client_get_state(cl))
799 case Client_Connecting: stat->num_connecting++; break;
800 case Client_Initializing: stat->num_initializing++; break;
801 case Client_Searching: stat->num_searching++; break;
802 case Client_Presenting: stat->num_presenting++; break;
803 case Client_Idle: stat->num_idle++; break;
804 case Client_Failed: stat->num_failed++; break;
805 case Client_Error: stat->num_error++; break;
810 stat->num_hits = se->total_hits;
811 stat->num_records = se->total_records;
813 stat->num_clients = count;
816 void start_http_listener(void)
819 struct conf_server *ser = global_parameters.server;
821 if (*global_parameters.listener_override)
822 strcpy(hp, global_parameters.listener_override);
825 strcpy(hp, ser->host ? ser->host : "");
830 sprintf(hp + strlen(hp), "%d", ser->port);
836 void start_proxy(void)
839 struct conf_server *ser = global_parameters.server;
841 if (*global_parameters.proxy_override)
842 strcpy(hp, global_parameters.proxy_override);
843 else if (ser->proxy_host || ser->proxy_port)
845 strcpy(hp, ser->proxy_host ? ser->proxy_host : "");
850 sprintf(hp + strlen(hp), "%d", ser->proxy_port);
856 http_set_proxyaddr(hp, ser->myurl ? ser->myurl : "");
859 /* void start_zproxy(void) */
861 /* struct conf_server *ser = global_parameters.server; */
863 /* if (*global_parameters.zproxy_override){ */
864 /* yaz_log(YLOG_LOG, "Z39.50 proxy %s", */
865 /* global_parameters.zproxy_override); */
869 /* else if (ser->zproxy_host || ser->zproxy_port) */
871 /* char hp[128] = ""; */
873 /* strcpy(hp, ser->zproxy_host ? ser->zproxy_host : ""); */
874 /* if (ser->zproxy_port) */
877 /* strcat(hp, ":"); */
879 /* strcat(hp, "@:"); */
881 /* sprintf(hp + strlen(hp), "%d", ser->zproxy_port); */
883 /* strcpy(global_parameters.zproxy_override, hp); */
884 /* yaz_log(YLOG_LOG, "Z39.50 proxy %s", */
885 /* global_parameters.zproxy_override); */
892 // Master list of connections we're handling events to
893 static IOCHAN channel_list = 0;
894 void pazpar2_add_channel(IOCHAN chan)
896 chan->next = channel_list;
900 void pazpar2_event_loop()
902 event_loop(&channel_list);
905 struct record *ingest_record(struct client *cl, Z_External *rec,
908 xmlDoc *xdoc = normalize_record(client_get_database(cl), rec);
910 struct record *record;
911 struct record_cluster *cluster;
912 struct session *se = client_get_session(cl);
913 xmlChar *mergekey, *mergekey_norm;
916 struct conf_service *service = global_parameters.server->service;
921 root = xmlDocGetRootElement(xdoc);
922 if (!(mergekey = xmlGetProp(root, (xmlChar *) "mergekey")))
924 yaz_log(YLOG_WARN, "No mergekey found in record");
929 record = record_create(se->nmem,
930 service->num_metadata, service->num_sortkeys);
931 record_assign_client(record, cl);
933 mergekey_norm = (xmlChar *) nmem_strdup(se->nmem, (char*) mergekey);
935 normalize7bit_mergekey((char *) mergekey_norm, 0);
937 cluster = reclist_insert(se->reclist,
938 global_parameters.server->service,
939 record, (char *) mergekey_norm,
941 if (global_parameters.dump_records)
942 yaz_log(YLOG_LOG, "Cluster id %d from %s (#%d)", cluster->recid,
943 client_get_database(cl)->database->url, record_no);
946 /* no room for record */
950 relevance_newrec(se->relevance, cluster);
953 // now parsing XML record and adding data to cluster or record metadata
954 for (n = root->children; n; n = n->next)
962 if (n->type != XML_ELEMENT_NODE)
964 if (!strcmp((const char *) n->name, "metadata"))
966 struct conf_metadata *ser_md = 0;
967 struct conf_sortkey *ser_sk = 0;
968 struct record_metadata **wheretoput = 0;
969 struct record_metadata *rec_md = 0;
970 int md_field_id = -1;
971 int sk_field_id = -1;
974 type = xmlGetProp(n, (xmlChar *) "type");
975 value = xmlNodeListGetString(xdoc, n->children, 0);
981 = conf_service_metadata_field_id(service, (const char *) type);
985 "Ignoring unknown metadata element: %s", type);
989 ser_md = &service->metadata[md_field_id];
991 if (ser_md->sortkey_offset >= 0){
992 sk_field_id = ser_md->sortkey_offset;
993 ser_sk = &service->sortkeys[sk_field_id];
996 // Find out where we are putting it - based on merge or not
997 if (ser_md->merge == Metadata_merge_no)
998 wheretoput = &record->metadata[md_field_id];
1000 wheretoput = &cluster->metadata[md_field_id];
1002 // create new record_metadata
1003 rec_md = record_metadata_create(se->nmem);
1005 // and polulate with data:
1006 // type based charmapping decisions follow here
1007 if (ser_md->type == Metadata_type_generic)
1010 char * p = (char *) value;
1011 p = normalize7bit_generic(p, " ,/.:([");
1013 rec_md->data.text = nmem_strdup(se->nmem, p);
1016 else if (ser_md->type == Metadata_type_year)
1018 if (extract7bit_years((char *) value, &first, &last) < 0)
1024 "Unknown type in metadata element %s", type);
1028 // and polulate with data:
1029 // assign cluster or record based on merge action
1030 if (ser_md->merge == Metadata_merge_unique)
1032 struct record_metadata *mnode;
1033 for (mnode = *wheretoput; mnode; mnode = mnode->next)
1034 if (!strcmp((const char *) mnode->data.text,
1039 rec_md->next = *wheretoput;
1040 *wheretoput = rec_md;
1043 else if (ser_md->merge == Metadata_merge_longest)
1046 || strlen(rec_md->data.text)
1047 > strlen((*wheretoput)->data.text))
1049 *wheretoput = rec_md;
1052 char *s = nmem_strdup(se->nmem, rec_md->data.text);
1053 if (!cluster->sortkeys[sk_field_id])
1054 cluster->sortkeys[sk_field_id] =
1055 nmem_malloc(se->nmem,
1056 sizeof(union data_types));
1057 normalize7bit_mergekey(s,
1058 (ser_sk->type == Metadata_sortkey_skiparticle));
1059 cluster->sortkeys[sk_field_id]->text = s;
1063 else if (ser_md->merge == Metadata_merge_all
1064 || ser_md->merge == Metadata_merge_no)
1066 rec_md->next = *wheretoput;
1067 *wheretoput = rec_md;
1069 else if (ser_md->merge == Metadata_merge_range)
1073 *wheretoput = rec_md;
1074 (*wheretoput)->data.number.min = first;
1075 (*wheretoput)->data.number.max = last;
1077 cluster->sortkeys[sk_field_id]
1082 if (first < (*wheretoput)->data.number.min)
1083 (*wheretoput)->data.number.min = first;
1084 if (last > (*wheretoput)->data.number.max)
1085 (*wheretoput)->data.number.max = last;
1090 union data_types *sdata
1091 = cluster->sortkeys[sk_field_id];
1092 yaz_log(YLOG_LOG, "SK range: %d-%d",
1093 sdata->number.min, sdata->number.max);
1099 // ranking of _all_ fields enabled ...
1101 relevance_countwords(se->relevance, cluster,
1102 (char *) value, ser_md->rank);
1104 // construct facets ...
1105 if (ser_md->termlist)
1107 if (ser_md->type == Metadata_type_year)
1110 sprintf(year, "%d", last);
1111 add_facet(se, (char *) type, year);
1114 sprintf(year, "%d", first);
1115 add_facet(se, (char *) type, year);
1119 add_facet(se, (char *) type, (char *) value);
1129 "Unexpected element %s in internal record", n->name);
1138 relevance_donerecord(se->relevance, cluster);
1139 se->total_records++;
1149 * indent-tabs-mode: nil
1151 * vim: shiftwidth=4 tabstop=8 expandtab