From 687d1431ba75a222ee963d3b9c54efa4ba4f1599 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 23 Apr 2012 12:23:52 +0200 Subject: [PATCH] Document rank may be dynamically defined in XSLT The document rank attributes, so far, has been statically defined in the target metadata settings. This may be overriden by rank attribute for internal XML document, if given. Semantica are the same: 0=disable, >0 : enable and multipler is value. --- doc/book.xml | 5 +++-- doc/pazpar2_conf.xml | 4 ++++ src/session.c | 18 +++++++++++++++--- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/doc/book.xml b/doc/book.xml index 4113aa7..9f96d75 100644 --- a/doc/book.xml +++ b/doc/book.xml @@ -579,7 +579,7 @@ - The Shining + The Shining King, Stephen @@ -604,7 +604,8 @@ records are never merged. The 'metadata' elements provide the meat of the elements -- the content. the 'type' attribute is used to match each element against processing rules that determine what - happens to the data element next. + happens to the data element next. The attribute, 'rank' specifies + specifies a multipler for ranking for this element. diff --git a/doc/pazpar2_conf.xml b/doc/pazpar2_conf.xml index 8aac27a..f66068e 100644 --- a/doc/pazpar2_conf.xml +++ b/doc/pazpar2_conf.xml @@ -269,6 +269,10 @@ elements of this type. The default is '0', which excludes this element from the rank calculation. + + For Pazpar2 1.6.13 and later, the rank may also defined + "per-document", by the normalization stylesheet. + diff --git a/src/session.c b/src/session.c index 16b7146..60f3813 100644 --- a/src/session.c +++ b/src/session.c @@ -1763,6 +1763,8 @@ static int ingest_to_cluster(struct client *cl, struct record_metadata *rec_md = 0; int md_field_id = -1; int sk_field_id = -1; + int rank = 0; + xmlChar *rank_str = 0; type = xmlGetProp(n, (xmlChar *) "type"); value = xmlNodeListGetString(xdoc, n->children, 1); @@ -1776,6 +1778,15 @@ static int ingest_to_cluster(struct client *cl, continue; ser_md = &service->metadata[md_field_id]; + + rank_str = xmlGetProp(n, (xmlChar *) "rank"); + if (rank_str) + { + rank = atoi((const char *) rank_str); + xmlFree(rank_str); + } + else + rank = ser_md->rank; if (ser_md->sortkey_offset >= 0) { @@ -1875,10 +1886,11 @@ static int ingest_to_cluster(struct client *cl, // ranking of _all_ fields enabled ... - if (ser_md->rank) + if (rank) + { relevance_countwords(se->relevance, cluster, - (char *) value, ser_md->rank, - ser_md->name); + (char *) value, rank, ser_md->name); + } // construct facets ... unless the client already has reported them if (ser_md->termlist && !client_has_facet(cl, (char *) type)) -- 1.7.10.4