ZOOM_facet_field_get_term(facets[facet_idx],
term_idx, &freq);
if (term)
- add_facet(se, p, term, freq);
+ add_facet(se, p, term, freq, cl);
}
break;
}
}
}
-static int apply_limit(struct session_database *sdb,
+static int apply_limit(struct client *cl,
facet_limits_t facet_limits,
WRBUF w_pqf, CCL_bibset ccl_map,
struct conf_service *service)
int i = 0;
const char *name;
const char *value;
+ struct session_database *sdb = client_get_database(cl);
NMEM nmem_tmp = nmem_create();
for (i = 0; (name = facet_limits_get(facet_limits, i, &value)); i++)
nmem_strsplit_escape2(nmem_tmp, "|", value, &values,
&num, 1, '\\', 1);
+ for (i = 0; i < num; i++)
+ {
+ const char *id = session_lookup_id_facet(cl->session,
+ cl, p, values[i]);
+ if (id)
+ values[i] = nmem_strdup(nmem_tmp, id);
+ }
nmem_strsplit_escape2(nmem_tmp, ",", s->value, &cvalues,
&cnum, 1, '\\', 1);
wrbuf_puts(w_pqf, " ");
}
- if (apply_limit(sdb, facet_limits, w_pqf, ccl_map, service))
+ if (apply_limit(cl, facet_limits, w_pqf, ccl_map, service))
{
ccl_qual_rm(&ccl_map);
return -2;
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,
+ 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_strdup(s->session_nmem, id);
+ t->term = nmem_strdup(s->session_nmem, term);
+ t->next = s->facet_id_list;
+ s->facet_id_list = t;
+}
+
+
+const char *session_lookup_id_facet(struct session *s, struct client *cl,
+ const char *type,
+ const char *term)
+{
+ struct facet_id *t = s->facet_id_list;
+ for (; t; t = t->next)
+ if (!strcmp(client_get_id(cl), t->id) &&
+ !strcmp(t->type, type) && !strcmp(t->term, term))
+ return t->id;
+ return 0;
+}
+
+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();
}
termlist_insert((*tp)->termlist, wrbuf_cstr(display_wrbuf),
wrbuf_cstr(facet_wrbuf), id, id_len, count);
+ if (id)
+ session_add_id_facet(s, cl, type, id, 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;
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
facet_limits_t facet_limits;
int clients_starting;
struct reclist_sortparms *sorted_results;
+ struct facet_id *facet_id_list;
};
struct statistics {
int ingest_xml_record(struct client *cl, xmlDoc *xdoc,
int record_no, NMEM nmem, int cached_copy);
void session_alert_watch(struct session *s, int what);
-void add_facet(struct session *s, const char *type, const char *value, int count);
+void add_facet(struct session *s, const char *type, const char *value, int count, struct client *cl);
int session_check_cluster_limit(struct session *se, struct record_cluster *rec);
void perform_termlist(struct http_channel *c, struct session *se, const char *name, int num, int version);
+
+const char *session_lookup_id_facet(struct session *s, struct client *cl,
+ const char *type, const char *term);
+
void session_log(struct session *s, int level, const char *fmt, ...)
#ifdef __GNUC__
__attribute__ ((format (printf, 3, 4)))