From 6590ecb69cda8c6e25fe137f0130996d2d1ccb9e Mon Sep 17 00:00:00 2001 From: Sebastian Hammer Date: Mon, 8 Jan 2007 19:39:12 +0000 Subject: [PATCH] Fixed bug related to ranking, introduced by 'metadata' update. Also introduced 'rank' attribute to service/metadata element. Specifies a 'boost' factor to apply a given element. Default=1, 0=don't use this field for ranking. --- etc/pazpar2.cfg | 6 +++--- src/config.c | 9 ++++++++- src/config.h | 1 + src/http_command.c | 3 ++- src/pazpar2.c | 5 +++-- src/relevance.c | 6 +++--- 6 files changed, 20 insertions(+), 10 deletions(-) diff --git a/etc/pazpar2.cfg b/etc/pazpar2.cfg index 2b84e08..5143d4a 100644 --- a/etc/pazpar2.cfg +++ b/etc/pazpar2.cfg @@ -5,10 +5,10 @@ - + - - + + diff --git a/src/config.c b/src/config.c index 46c3f64..2de8479 100644 --- a/src/config.c +++ b/src/config.c @@ -1,4 +1,4 @@ -/* $Id: config.c,v 1.5 2007-01-08 18:32:35 quinn Exp $ */ +/* $Id: config.c,v 1.6 2007-01-08 19:39:12 quinn Exp $ */ #include @@ -54,6 +54,7 @@ static struct conf_service *parse_service(xmlNode *node) xmlChar *merge = xmlGetProp(n, "merge"); xmlChar *type = xmlGetProp(n, "type"); xmlChar *termlist = xmlGetProp(n, "termlist"); + xmlChar *rank = xmlGetProp(n, "rank"); if (!name) { @@ -87,6 +88,11 @@ static struct conf_service *parse_service(xmlNode *node) else md->termlist = 0; + if (rank) + md->rank = atoi(rank); + else + md->rank = 1; + if (type) { if (!strcmp(type, "generic")) @@ -148,6 +154,7 @@ static struct conf_service *parse_service(xmlNode *node) xmlFree(sortkey); xmlFree(merge); xmlFree(termlist); + xmlFree(rank); md_node++; } else diff --git a/src/config.h b/src/config.h index 346707a..8b3cfd2 100644 --- a/src/config.h +++ b/src/config.h @@ -11,6 +11,7 @@ struct conf_metadata char *name; // The name of this element. Output by normalization stylesheet int brief; // Is this element to be returned in the brief format? int termlist;// Is this field to be treated as a termlist for browsing? + int rank; // Rank factor. 0 means don't use this field for ranking, 1 is default enum { Metadata_type_generic, // Generic text field diff --git a/src/http_command.c b/src/http_command.c index 66c903c..32a1329 100644 --- a/src/http_command.c +++ b/src/http_command.c @@ -1,5 +1,5 @@ /* - * $Id: http_command.c,v 1.10 2007-01-08 18:32:35 quinn Exp $ + * $Id: http_command.c,v 1.11 2007-01-08 19:39:12 quinn Exp $ */ #include @@ -316,6 +316,7 @@ static void show_records(struct http_channel *c, int active) struct conf_service *service = global_parameters.server->service; int imeta; + yaz_log(YLOG_LOG, "Record, rank=%d", rec->relevance); wrbuf_puts(c->wrbuf, "\n"); for (imeta = 0; imeta < service->num_metadata; imeta++) { diff --git a/src/pazpar2.c b/src/pazpar2.c index 22ec100..17ce62f 100644 --- a/src/pazpar2.c +++ b/src/pazpar2.c @@ -1,4 +1,4 @@ -/* $Id: pazpar2.c,v 1.19 2007-01-08 18:32:35 quinn Exp $ */; +/* $Id: pazpar2.c,v 1.20 2007-01-08 19:39:12 quinn Exp $ */; #include #include @@ -545,7 +545,8 @@ static struct record *ingest_record(struct client *cl, Z_External *rec) else yaz_log(YLOG_WARN, "Don't know how to merge on element name %s", md->name); - relevance_countwords(se->relevance, cluster, value, 4); + if (md->rank) + relevance_countwords(se->relevance, cluster, value, md->rank); if (md->termlist) add_facet(se, type, value); xmlFree(type); diff --git a/src/relevance.c b/src/relevance.c index c7c3f12..b1713e0 100644 --- a/src/relevance.c +++ b/src/relevance.c @@ -1,5 +1,5 @@ /* - * $Id: relevance.c,v 1.5 2007-01-08 18:32:35 quinn Exp $ + * $Id: relevance.c,v 1.6 2007-01-08 19:39:12 quinn Exp $ */ #include @@ -194,8 +194,8 @@ static int comp(const void *p1, const void *p2) #else static int comp(const void *p1, const void *p2) { - struct record **r1 = (struct record **) p1; - struct record **r2 = (struct record **) p2; + struct record_cluster **r1 = (struct record_cluster **) p1; + struct record_cluster **r2 = (struct record_cluster **) p2; return (*r2)->relevance - (*r1)->relevance; } #endif -- 1.7.10.4