From: Adam Dickmeiss Date: Mon, 23 Apr 2012 10:23:52 +0000 (+0200) Subject: Document rank may be dynamically defined in XSLT X-Git-Tag: v1.6.13~16^2~2^2~22 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=687d1431ba75a222ee963d3b9c54efa4ba4f1599;p=pazpar2-moved-to-github.git 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. --- 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))