From: Heikki Levanto Date: Mon, 27 Jul 2015 13:34:56 +0000 (+0200) Subject: PAZ-1013: Do not re-search if facet-id mapping not found X-Git-Tag: v1.11.3~2 X-Git-Url: http://jsfdemo.indexdata.com/?a=commitdiff_plain;h=186e99a6b10f92bf994322f4f3eacd64f56c1a13;p=pazpar2-moved-to-github.git PAZ-1013: Do not re-search if facet-id mapping not found Conflicts: src/client.c src/session.c --- diff --git a/NEWS b/NEWS index 5db352c..118c3f8 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,7 @@ +--- next version + +fix PAZ-1013 - do not re-search if facetlimit scan fails to find value + --- 1.11.2 2015/07/21 Fix PAZ-1015, which prevented the docs from being built, and therefore diff --git a/src/client.c b/src/client.c index b498751..1c53733 100644 --- a/src/client.c +++ b/src/client.c @@ -1386,7 +1386,21 @@ static int apply_limit(struct client *cl, cl, name, values[i]); if (id) - values[i] = nmem_strdup(nmem_tmp, id); + { + if ( *id ) + { + values[i] = nmem_strdup(nmem_tmp, id); + yaz_log(YLOG_DEBUG, + "apply_limit: s='%s' found id '%s'",s->name,id ); + } + else + { + yaz_log(YLOG_DEBUG, + "apply_limit: %s: term '%s' not found, failing client", + s->name, values[i] ); + ret = -1; + } + } } nmem_strsplit_escape2(nmem_tmp, ",", s->value, &cvalues, &cnum, 1, '\\', 1); diff --git a/src/session.c b/src/session.c index c607418..b590001 100644 --- a/src/session.c +++ b/src/session.c @@ -228,18 +228,27 @@ static void session_add_id_facet(struct session *s, struct client *cl, } +// Look up a facet term, and return matching id +// If facet type not found, returns 0 +// If facet type found, but no matching term, returns "" const char *session_lookup_id_facet(struct session *s, struct client *cl, const char *type, const char *term) { + char *retval = 0; struct facet_id *t = s->facet_id_list; - for (; t; t = t->next) - if (!strcmp(client_get_id(cl), t->client_id) && - !strcmp(t->type, type) && !strcmp(t->term, term)) + for (; t; t = t->next) + { + if (!strcmp(client_get_id(cl), t->client_id) && !strcmp(t->type, type) ) { - return t->id; + retval = ""; + if ( !strcmp(t->term, term)) + { + return t->id; + } } - return 0; + } + return retval; } void add_facet(struct session *s, const char *type, const char *value, int count, struct client *cl)