* Copyright (C) 1995-2010 Index Data
* See the file LICENSE for details.
*/
-
/** \file
* \brief yaz-ztest Generic Frontend Server
*/
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include <stdio.h>
#include <math.h>
Sleep( (DWORD) (d * 1000));
#else
struct timeval tv;
- tv.tv_sec = floor(d);
- tv.tv_usec = (d - floor(d)) * 1000000;
+ tv.tv_sec = d;
+ tv.tv_usec = (d - (long) d) * 1000000;
select(0, 0, 0, 0, &tv);
#endif
}
int index;
int freq = 100;
int length = strlen(facet_name) + 10;
- char key[length];
+ char *key = odr_malloc(odr, length);
key[0] = '\0';
for (index = 0; index < facet_field->num_terms; index++) {
Z_Term *term;
Z_FacetTerm *facet_term;
- // sprintf(key, "%s%d", facet_name, index);
- //yaz_log(YLOG_DEBUG, "facet add term %s %d %s", facet_name, index, key);
+ sprintf(key, "%s%d", facet_name, index);
+ yaz_log(YLOG_DEBUG, "facet add term %s %d %s", facet_name, index, key);
term = term_create(odr, key);
facet_term = facet_term_create(odr, term, freq);
freq = freq - 10 ;
Z_FacetList *new_list = facet_list_create(odr, facet_list->num);
for (index = 0; index < facet_list->num; index++) {
- struct attrvalues attrvalues;
- facet_struct_init(&attrvalues);
- attrvalues.limit = 10;
- yaz_log(YLOG_LOG, "Attributes: %s %s %d ", attrvalues.useattr, attrvalues.useattrbuff, attrvalues.limit);
- facetattrs(facet_list->elements[index]->attributes, &attrvalues);
- yaz_log(YLOG_LOG, "Attributes: %s %s %d ", attrvalues.useattr, attrvalues.useattrbuff, attrvalues.limit);
+ struct yaz_facet_attr attrvalues;
+ yaz_facet_attr_init(&attrvalues);
+ attrvalues.limit = 0;
+ yaz_facet_attr_get_z_attributes(facet_list->elements[index]->attributes,
+ &attrvalues);
+ yaz_log(YLOG_LOG, "Attributes: %s %d ", attrvalues.useattr, attrvalues.limit);
if (attrvalues.errstring)
yaz_log(YLOG_LOG, "Error parsing attributes: %s", attrvalues.errstring);
- if (attrvalues.limit > 0) {
+ if (attrvalues.limit > 0 && attrvalues.useattr) {
new_list->elements[new_index] = facet_field_create(odr, facet_list->elements[index]->attributes, attrvalues.limit);
addterms(odr, new_list->elements[new_index], attrvalues.useattr);
new_index++;
}
+ else {
+ yaz_log(YLOG_DEBUG, "Facet: skipping %s due to 0 limit.", attrvalues.useattr);
+ }
+
}
new_list->num = new_index;
if (new_index > 0) {
oiu->which = Z_OtherInfo_externallyDefinedInfo;
oiu->information.externallyDefinedInfo = odr_malloc(odr, sizeof(*oiu->information.externallyDefinedInfo));
oiu->information.externallyDefinedInfo->direct_reference = odr_oiddup(odr, yaz_oid_userinfo_facet_1);
+ oiu->information.externallyDefinedInfo->descriptor = 0;
+ oiu->information.externallyDefinedInfo->indirect_reference = 0;
oiu->information.externallyDefinedInfo->which = Z_External_userFacets;
oiu->information.externallyDefinedInfo->u.facetList = new_list;
oi->list[0] = oiu;
if (1)
{
- /* TODO Not general. Only handles one (Facet) OtherInformation. Overwrite */
- Z_FacetList *facet_list = extract_facet_request(rr->stream, rr->search_input);
-
+ Z_FacetList *facet_list = yaz_oi_get_facetlist(&rr->search_input);
if (facet_list) {
yaz_log(YLOG_LOG, "%d Facets in search request.", facet_list->num);
rr->search_info = build_facet_response(rr->stream, facet_list);