From: Adam Dickmeiss Date: Thu, 2 Jul 2015 12:42:00 +0000 (+0200) Subject: facet ID term map - take 1 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=44cfe47e00cc8fba5097b16b1d62b1321b8c4268;p=pazpar2-moved-to-github.git facet ID term map - take 1 In this scenario if pz:facetmap has a split: prefix, eg Then the subjects will be split into a normal display facet and an ID - separated by first colon. This makes it possible to limit _one_ target's native facet IDs but will not work for anything else - because these definitions are target specific!! --- diff --git a/perf/bash/pp2client.sh b/perf/bash/pp2client.sh index 03b0421..c39077d 100755 --- a/perf/bash/pp2client.sh +++ b/perf/bash/pp2client.sh @@ -93,6 +93,7 @@ if [ "$TIME" != "" ] ; then else wget -q -O ${TMP_DIR}$OF.show.xml "$H?command=show&session=$S&sort=relevance&start=0&num=100&block=1" fi +wget -q -O ${TMP_DIR}$OF.termlist.xml "$H?command=termlist&session=$S" wget -q -O ${TMP_DIR}$OF.bytarget.xml "$H?command=bytarget&session=$S" wget -q -O ${TMP_DIR}$OF.stat.xml "$H?command=stat&session=$S" wget -q -O ${TMP_DIR}$OF.info.xml "$H?command=info" diff --git a/src/session.c b/src/session.c index e67cd10..e7d5b9c 100644 --- a/src/session.c +++ b/src/session.c @@ -207,9 +207,27 @@ void add_facet(struct session *s, const char *type, const char *value, int count { WRBUF facet_wrbuf = wrbuf_alloc(); WRBUF display_wrbuf = wrbuf_alloc(); + const char *id = 0; + size_t id_len = 0; - session_normalize_facet(s, type, value, display_wrbuf, facet_wrbuf); + yaz_log(YLOG_LOG, "add_facet type=%s value=%s count=%d", + type, value, count); + + /* inspect pz:facetmap:split:name ?? */ + if (!strncmp(type, "split:", 6)) + { + const char *cp = strchr(value, ':'); + if (cp) + { + id = value; + id_len = cp - value; + value = cp + 1; + yaz_log(YLOG_LOG, "strip id=%s value=%s", id, value); + } + type += 6; + } + session_normalize_facet(s, type, value, display_wrbuf, facet_wrbuf); if (wrbuf_len(facet_wrbuf)) { struct named_termlist **tp = &s->termlists; @@ -224,7 +242,7 @@ void add_facet(struct session *s, const char *type, const char *value, int count (*tp)->next = 0; } termlist_insert((*tp)->termlist, wrbuf_cstr(display_wrbuf), - wrbuf_cstr(facet_wrbuf), count); + wrbuf_cstr(facet_wrbuf), id, id_len, count); } wrbuf_destroy(facet_wrbuf); wrbuf_destroy(display_wrbuf); @@ -1216,7 +1234,12 @@ void perform_termlist(struct http_channel *c, struct session *se, wrbuf_puts(c->wrbuf, ""); wrbuf_xmlputs(c->wrbuf, p[i]->display_term); wrbuf_puts(c->wrbuf, ""); - + if (p[i]->id) + { + wrbuf_puts(c->wrbuf, ""); + wrbuf_xmlputs(c->wrbuf, p[i]->id); + wrbuf_puts(c->wrbuf, ""); + } wrbuf_printf(c->wrbuf, "%d", p[i]->frequency); diff --git a/src/termlists.c b/src/termlists.c index 8f06a47..79e88ee 100644 --- a/src/termlists.c +++ b/src/termlists.c @@ -62,7 +62,8 @@ struct termlist *termlist_create(NMEM nmem) } void termlist_insert(struct termlist *tl, const char *display_term, - const char *norm_term, int freq) + const char *norm_term, const char *id, size_t id_len, + int freq) { unsigned int bucket; struct termlist_bucket **p; @@ -87,6 +88,7 @@ void termlist_insert(struct termlist *tl, const char *display_term, new->term.norm_term = nmem_strdup(tl->nmem, buf); new->term.display_term = *display_term ? nmem_strdup(tl->nmem, display_term) : new->term.norm_term; + new->term.id = id ? nmem_strdupn(tl->nmem, id, id_len) : 0; new->term.frequency = freq; new->next = 0; *p = new; diff --git a/src/termlists.h b/src/termlists.h index 8502e3e..0d5310a 100644 --- a/src/termlists.h +++ b/src/termlists.h @@ -26,6 +26,7 @@ struct termlist_score { char *norm_term; char *display_term; + char *id; int frequency; }; @@ -33,7 +34,8 @@ struct termlist; struct termlist *termlist_create(NMEM nmem); void termlist_insert(struct termlist *tl, const char *display_term, - const char *norm_term, int freq); + const char *norm_term, + const char *id, size_t id_len, int freq); struct termlist_score **termlist_highscore(struct termlist *tl, int *len, NMEM nmem);