From c453835b907746dd07babd58ac15ce11dca2eb7b Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 1 Dec 2008 08:49:56 +0100 Subject: [PATCH] Added setting to specify pqf prefix, to support database subset selection, etc. --- doc/pazpar2_conf.xml | 13 +++++++++++++ src/client.c | 7 +++++++ src/settings.c | 1 + src/settings.h | 2 +- 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/doc/pazpar2_conf.xml b/doc/pazpar2_conf.xml index 745cab4..4b80887 100644 --- a/doc/pazpar2_conf.xml +++ b/doc/pazpar2_conf.xml @@ -797,6 +797,19 @@ + + + pz:pqf_prefix + + + Allows you to specify an arbitrary PQF query language substring. The provided + string is prefixed the user's query after it has been normalized to PQF + internally in pazpar2. This allows you to attach complex 'filters' to + queries for a gien target, sometimes necessary to select sub-catalogs + in union catalog systems, etc. + + + diff --git a/src/client.c b/src/client.c index 076b5e5..6473597 100644 --- a/src/client.c +++ b/src/client.c @@ -990,6 +990,8 @@ int client_parse_query(struct client *cl, const char *query) struct ccl_rpn_node *cn; int cerror, cpos; CCL_bibset ccl_map = prepare_cclmap(cl); + struct session_database *sdb = client_get_database(cl); + const char *pqf_prefix = session_setting_oneval(sdb, PZ_PQF_PREFIX); if (!ccl_map) return -1; @@ -1004,6 +1006,11 @@ int client_parse_query(struct client *cl, const char *query) return -1; } wrbuf_rewind(se->wrbuf); + if (*pqf_prefix) + { + wrbuf_puts(se->wrbuf, pqf_prefix); + wrbuf_puts(se->wrbuf, " "); + } ccl_pquery(se->wrbuf, cn); xfree(cl->pquery); cl->pquery = xstrdup(wrbuf_cstr(se->wrbuf)); diff --git a/src/settings.c b/src/settings.c index bea5da7..ef0ea22 100644 --- a/src/settings.c +++ b/src/settings.c @@ -63,6 +63,7 @@ static char *hard_settings[] = { "pz:ip", "pz:zproxy", "pz:apdulog", + "pz:pqf_prefix", 0 }; diff --git a/src/settings.h b/src/settings.h index 65e77b2..fff607c 100644 --- a/src/settings.h +++ b/src/settings.h @@ -35,7 +35,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define PZ_IP 12 #define PZ_ZPROXY 13 #define PZ_APDULOG 14 - +#define PZ_PQF_PREFIX 15 struct setting { -- 1.7.10.4