-#ifdef RETIRED
-
-void client_present_response(struct client *cl, Z_APDU *a)
-{
- Z_PresentResponse *r = a->u.presentResponse;
- Z_Records *recs = r->records;
-
- if (recs && recs->which == Z_Records_NSD)
- {
- WRBUF w = wrbuf_alloc();
-
- Z_DiagRec dr, *dr_p = &dr;
- dr.which = Z_DiagRec_defaultFormat;
- dr.u.defaultFormat = recs->u.nonSurrogateDiagnostic;
-
- wrbuf_printf(w, "Present response NSD %s: ",
- cl->database->database->url);
-
- cl->diagnostic = diag_to_wrbuf(&dr_p, 1, w);
-
- yaz_log(YLOG_WARN, "%s", wrbuf_cstr(w));
-
- cl->state = Client_Error;
- wrbuf_destroy(w);
-
- client_show_raw_error(cl, "non surrogate diagnostics");
- }
- else if (recs && recs->which == Z_Records_multipleNSD)
- {
- WRBUF w = wrbuf_alloc();
-
- wrbuf_printf(w, "Present response multipleNSD %s: ",
- cl->database->database->url);
- cl->diagnostic =
- diag_to_wrbuf(recs->u.multipleNonSurDiagnostics->diagRecs,
- recs->u.multipleNonSurDiagnostics->num_diagRecs,
- w);
- yaz_log(YLOG_WARN, "%s", wrbuf_cstr(w));
- cl->state = Client_Error;
- wrbuf_destroy(w);
- }
- else if (recs && !*r->presentStatus && cl->state != Client_Error)
- {
- yaz_log(YLOG_DEBUG, "Good Present response %s",
- cl->database->database->url);
-
- // we can mix show raw and normal show ..
- if (cl->show_raw && cl->show_raw->active)
- {
- cl->show_raw->active = 0; // no longer active
- ingest_raw_records(cl, recs);
+static int client_set_facets_request(struct client *cl, ZOOM_connection link) {
+ int index = 0;
+ struct session_database *sdb = client_get_database(cl);
+ const char *opt_facet_term_sort = session_setting_oneval(sdb, PZ_TERMLIST_TERM_SORT);
+ const char *opt_facet_term_count = session_setting_oneval(sdb, PZ_TERMLIST_TERM_COUNT);
+ struct session *session = client_get_session(cl);
+ struct conf_service *service = session->service;
+ int num = service->num_metadata;
+ yaz_log(YLOG_DEBUG, "Facet settings, sort: %s count: %s", opt_facet_term_sort, opt_facet_term_count);
+ WRBUF wrbuf = wrbuf_alloc();
+ int first = 1;
+ for (index = 0; index < num; index++) {
+ struct conf_metadata *conf_meta = &service->metadata[index];
+ if (conf_meta->termlist) {
+ if (first)
+ first = 0;
+ else
+ wrbuf_puts(wrbuf, ",");
+ wrbuf_printf(wrbuf, "@attr 1=%s ", conf_meta->name);
+
+ if (opt_facet_term_sort && opt_facet_term_sort[0] != '\0') {
+ wrbuf_printf(wrbuf, " @attr 2=%s ", opt_facet_term_sort);
+ }
+ if (opt_facet_term_count && opt_facet_term_count[0] != '\0') {
+ wrbuf_printf(wrbuf, " @attr 3=%s ", opt_facet_term_count);
+ }