From: Dennis Schafroth Date: Wed, 19 Sep 2012 13:56:55 +0000 (+0200) Subject: Configuration of default sort order. Default to previous hardcoded "relevance" X-Git-Tag: v1.6.20~17 X-Git-Url: http://sru.miketaylor.org.uk/?a=commitdiff_plain;h=018fbd9f5f6729d8488ba808da700df30fbb9711;p=pazpar2-moved-to-github.git Configuration of default sort order. Default to previous hardcoded "relevance" --- diff --git a/src/pazpar2_config.c b/src/pazpar2_config.c index 6e7652c..ca16ea5 100644 --- a/src/pazpar2_config.c +++ b/src/pazpar2_config.c @@ -137,6 +137,7 @@ struct conf_service *service_init(struct conf_server *server, service->charsets = 0; service->id = service_id ? nmem_strdup(nmem, service_id) : 0; + // Setup a dictionary from server. service->dictionary = 0; @@ -156,6 +157,8 @@ struct conf_service *service_init(struct conf_server *server, = nmem_malloc(nmem, sizeof(struct conf_metadata) * service->num_metadata); service->num_sortkeys = num_sortkeys; + + service->default_sort = nmem_strdup(nmem, "relevance"); service->sortkeys = 0; if (service->num_sortkeys) service->sortkeys @@ -629,6 +632,21 @@ static struct conf_service *service_create_static(struct conf_server *server, } xmlFree(rank_cluster); } + else if (!strcmp((const char *) n->name, "sort-default")) + { + char *default_sort = (char *) xmlGetProp(n, (xmlChar *) "field"); + + if (default_sort && strcmp(default_sort, "")) { + service->default_sort = nmem_strdup(service->nmem, default_sort); + yaz_log(YLOG_LOG, "service %d: default sort order configured to: %s", service_id, default_sort); + } + else + { + yaz_log(YLOG_FATAL, "default sort order is invalid: %s", default_sort); + return 0; + } + xmlFree(default_sort); + } else { yaz_log(YLOG_FATAL, "Bad element: %s", n->name); diff --git a/src/pazpar2_config.h b/src/pazpar2_config.h index f3960b2..1cad37a 100644 --- a/src/pazpar2_config.h +++ b/src/pazpar2_config.h @@ -117,6 +117,7 @@ struct conf_service int z3950_session_timeout; int z3950_operation_timeout; int rank_cluster; + char *default_sort; int ref_count; /* duplicated from conf_server */