From: Dennis Schafroth Date: Wed, 29 Dec 2010 22:38:53 +0000 (+0100) Subject: Add term factor calculation. X-Git-Tag: v1.5.1~8 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=c0843c36c17418433437a7742a49f78c8bc41342;p=pazpar2-moved-to-github.git Add term factor calculation. Factoring pazpar2 term count up with total hits / pz:maxrecs if PZ_TERMLIST_TERM_FACTOR --- diff --git a/src/session.c b/src/session.c index 710bc2e..339411a 100644 --- a/src/session.c +++ b/src/session.c @@ -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,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define MAX_CHUNK 15 +inline int max(int a, int b) +{ + return (a > b) ? a : b; +} + + // Note: Some things in this structure will eventually move to configuration struct parameters global_parameters = { @@ -1263,6 +1270,18 @@ static int ingest_to_cluster(struct client *cl, record, mergekey_norm, &se->total_merged); + + int use_term_factor = session_setting_oneval(sdb, PZ_TERMLIST_TERM_FACTOR); + int term_factor = 1; + + 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 +1451,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