run_icu(s, icu_chain_id, value, facet_wrbuf, display_wrbuf);
}
-void add_facet(struct session *s, const char *type, const char *value, int count)
+struct facet_id {
+ char *client_id;
+ char *type;
+ char *id;
+ char *term;
+ struct facet_id *next;
+};
+
+static void session_add_id_facet(struct session *s, struct client *cl,
+ const char *type,
+ const char *id,
+ size_t id_len,
+ const char *term)
+{
+ struct facet_id *t = nmem_malloc(s->session_nmem, sizeof(*t));
+
+ t->client_id = nmem_strdup(s->session_nmem, client_get_id(cl));
+ t->type = nmem_strdup(s->session_nmem, type);
+ t->id = nmem_strdupn(s->session_nmem, id, id_len);
+ t->term = nmem_strdup(s->session_nmem, term);
+ t->next = s->facet_id_list;
+ s->facet_id_list = t;
+}
+
+
+// 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) )
+ {
+ retval = "";
+ if ( !strcmp(t->term, term))
+ {
+ return t->id;
+ }
+ }
+ }
+ return retval;
+}
+
+void add_facet(struct session *s, const char *type, const char *value, int count, struct client *cl)
{
WRBUF facet_wrbuf = wrbuf_alloc();
WRBUF display_wrbuf = wrbuf_alloc();
+ const char *id = 0;
+ size_t id_len = 0;
+ /* 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;
+ }
+ type += 6;
+ }
session_normalize_facet(s, type, value, display_wrbuf, facet_wrbuf);
-
+ yaz_log(YLOG_DEBUG,"add_facet t='%s' v='%s' id='%s' d='%s' f='%s'",
+ type, value, id, wrbuf_cstr(display_wrbuf), wrbuf_cstr(facet_wrbuf) );
if (wrbuf_len(facet_wrbuf))
{
struct named_termlist **tp = &s->termlists;
(*tp)->next = 0;
}
termlist_insert((*tp)->termlist, wrbuf_cstr(display_wrbuf),
- wrbuf_cstr(facet_wrbuf), count);
+ wrbuf_cstr(facet_wrbuf), id, id_len, count);
+ if (id)
+ session_add_id_facet(s, cl, type, id, id_len,
+ wrbuf_cstr(display_wrbuf));
}
wrbuf_destroy(facet_wrbuf);
wrbuf_destroy(display_wrbuf);
session->clients_cached = 0;
session->settings_modified = 0;
session->session_nmem = nmem;
+ session->facet_id_list = 0;
session->nmem = nmem_create();
session->databases = 0;
session->sorted_results = 0;
session_settings_dump(se, client_get_database(cl), w);
res[*count].settings_xml = nmem_strdup(nmem, wrbuf_cstr(w));
wrbuf_rewind(w);
- wrbuf_puts(w, "");
- res[*count].suggestions_xml = nmem_strdup(nmem, client_get_suggestions_xml(cl, w));
+ res[*count].suggestions_xml =
+ nmem_strdup(nmem, client_get_suggestions_xml(cl, w));
+
+ res[*count].query_data =
+ client_get_query(cl, &res[*count].query_type, nmem);
wrbuf_destroy(w);
(*count)++;
}
wrbuf_puts(c->wrbuf, "<name>");
wrbuf_xmlputs(c->wrbuf, p[i]->display_term);
wrbuf_puts(c->wrbuf, "</name>");
-
wrbuf_printf(c->wrbuf,
"<frequency>%d</frequency>",
p[i]->frequency);
break;
case Metadata_type_relevance:
case Metadata_type_position:
+ case Metadata_type_retrieval:
return 0;
}
return rec_md;
char year[64];
sprintf(year, "%d", rec_md->data.number.max);
- add_facet(se, (char *) type, year, term_factor);
+ add_facet(se, (char *) type, year, term_factor, cl);
if (rec_md->data.number.max != rec_md->data.number.min)
{
sprintf(year, "%d", rec_md->data.number.min);
- add_facet(se, (char *) type, year, term_factor);
+ add_facet(se, (char *) type, year, term_factor, cl);
}
}
else
- add_facet(se, type, wrbuf_cstr(wrbuf_disp), term_factor);
+ add_facet(se, type, wrbuf_cstr(wrbuf_disp), term_factor, cl);
}
}
else