X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=src%2Fsession.c;h=7e7a489640a549f815e30eb6392a3ea81eb4f620;hb=d99076f5fdc60ee076aba83c897e2630be158060;hp=710bc2e0e3f81a330d488e24cb7b72fb555170c4;hpb=5bb55be401f739bf7405a6cb04528e3bc9f93b5f;p=pazpar2-moved-to-github.git diff --git a/src/session.c b/src/session.c index 710bc2e..7e7a489 100644 --- a/src/session.c +++ b/src/session.c @@ -1,5 +1,5 @@ /* This file is part of Pazpar2. - Copyright (C) 2006-2010 Index Data + Copyright (C) 2006-2011 Index Data Pazpar2 is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -41,6 +41,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include #include +#include #include #include @@ -79,6 +80,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define MAX_CHUNK 15 +#define MAX(a,b) ((a)>(b)?(a):(b)) + // Note: Some things in this structure will eventually move to configuration struct parameters global_parameters = { @@ -1263,6 +1266,21 @@ static int ingest_to_cluster(struct client *cl, record, mergekey_norm, &se->total_merged); + + const char *use_term_factor_str = session_setting_oneval(sdb, PZ_TERMLIST_TERM_FACTOR); + int use_term_factor = 1; + int term_factor = 1; + if (use_term_factor_str) + use_term_factor = atoi(use_term_factor_str); + + if (use_term_factor) { + int maxrecs = client_get_maxrecs(cl); + int hits = (int) client_get_hits(cl); + term_factor = MAX(hits, maxrecs) / MAX(1, maxrecs); + assert(term_factor >= 1); + yaz_log(YLOG_DEBUG, "Using term factor %d ", term_factor); + } + if (!cluster) return -1; if (global_parameters.dump_records) @@ -1432,15 +1450,16 @@ static int ingest_to_cluster(struct client *cl, { char year[64]; sprintf(year, "%d", rec_md->data.number.max); - add_facet(se, (char *) type, year, 1); + + add_facet(se, (char *) type, year, term_factor); if (rec_md->data.number.max != rec_md->data.number.min) { sprintf(year, "%d", rec_md->data.number.min); - add_facet(se, (char *) type, year, 1); + add_facet(se, (char *) type, year, term_factor); } } else - add_facet(se, (char *) type, (char *) value, 1); + add_facet(se, (char *) type, (char *) value, term_factor); } // cleaning up