X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fclient.c;fp=src%2Fclient.c;h=93671536adad71e5407536649f19c93d69a9f3b8;hb=9ebc11737580bcae95386cb76539650807b8f166;hp=16099ba7d13782bf2071fa3468863853fd0d7ca2;hpb=103e761280b7b48dc21cfba6732badf8e13f9624;p=pazpar2-moved-to-github.git diff --git a/src/client.c b/src/client.c index 16099ba..9367153 100644 --- a/src/client.c +++ b/src/client.c @@ -945,8 +945,41 @@ static char *make_solrquery(struct client *cl) return r; } +static void apply_limit(struct session_database *sdb, + facet_limits_t facet_limits, + WRBUF w) +{ + int i = 0; + const char *name; + const char *value; + for (i = 0; (name = facet_limits_get(facet_limits, i, &value)); i++) + { + struct setting *s = 0; + + for (s = sdb->settings[PZ_FACETMAP]; s; s = s->next) + { + const char *p = strchr(s->name + 3, ':'); + if (p && !strcmp(p + 1, name) && s->value && s->value[0]) + { + wrbuf_insert(w, 0, "@and ", 5); + wrbuf_puts(w, " @attr 1="); + yaz_encode_pqf_term(w, s->value, strlen(s->value)); + wrbuf_puts(w, " "); + yaz_encode_pqf_term(w, value, strlen(value)); + break; + } + } + if (!s) + { + yaz_log(YLOG_WARN, "facet %s used, but no facetmap defined", + name); + } + } +} + // Parse the query given the settings specific to this client -int client_parse_query(struct client *cl, const char *query) +int client_parse_query(struct client *cl, const char *query, + facet_limits_t facet_limits) { struct session *se = client_get_session(cl); struct session_database *sdb = client_get_database(cl); @@ -979,6 +1012,8 @@ int client_parse_query(struct client *cl, const char *query) wrbuf_puts(se->wrbuf, " "); } + apply_limit(sdb, facet_limits, se->wrbuf); + if (!pqf_strftime || !*pqf_strftime) ccl_pquery(se->wrbuf, cn); else