/* This file is part of the YAZ toolkit.
- * Copyright (C) 1995-2011 Index Data
+ * Copyright (C) 1995-2012 Index Data
* See the file LICENSE for details.
*/
#include <yaz/oid_db.h>
#include <yaz/oid_std.h>
#include <yaz/otherinfo.h>
+#include <yaz/pquery.h>
#include <assert.h>
void yaz_oi_set_facetlist(
return 0;
z_external = oi->information.externallyDefinedInfo;
- if (z_external && z_external->which == Z_External_userFacets) {
+ if (z_external && z_external->which == Z_External_userFacets)
return z_external->u.facetList;
- }
return 0;
}
sprintf(av->useattrbuff, ODR_INT_PRINTF, *ae->value.numeric);
av->useattr = av->useattrbuff;
}
-} /* useattr */
+}
-/* TODO rename to sortorder attr */
-static void relationattr(Z_AttributeElement *ae, struct yaz_facet_attr *av)
+static void sortorderattr(Z_AttributeElement *ae, struct yaz_facet_attr *av)
{
if (ae->which == Z_AttributeValue_numeric)
{
if (*ae->value.numeric == 0)
av->relation = "desc";
else if (*ae->value.numeric == 1)
- av->relation = "asc";
- else
- if (*ae->value.numeric == 3) {
+ av->relation = "asc";
+ else if (*ae->value.numeric == 3)
av->relation = "unknown/unordered";
- } else {
+ else
+ {
av->errcode = YAZ_BIB1_UNSUPP_RELATION_ATTRIBUTE;
sprintf(av->useattrbuff, ODR_INT_PRINTF,
- *ae-> attributeType);
+ *ae-> attributeType);
av->errstring = av->useattrbuff;
}
}
av->errcode = YAZ_BIB1_UNSUPP_RELATION_ATTRIBUTE;
av->errstring = "non-numeric relation attribute";
}
-} /* relationattr */
+}
static void limitattr(Z_AttributeElement *ae, struct yaz_facet_attr *av)
{
av->errcode = YAZ_BIB1_UNSUPP_ATTRIBUTE;
av->errstring = "non-numeric limit attribute";
}
-} /* relationattr */
+}
/* Get the index to be searched from the attributes.
@attr 1
{
int i;
Z_AttributeElement *ae;
- for (i=0; i < attributes->num_attributes; i++) {
+ for (i = 0; i < attributes->num_attributes; i++)
+ {
ae = attributes->attributes[i];
/* ignoring the attributeSet here */
if (*ae->attributeType == 1)
}
else if (*ae->attributeType == 2)
{ /* sortorder */
- relationattr(ae, av);
+ sortorderattr(ae, av);
}
else if (*ae->attributeType == 3)
{ /* limit */
return;
} /* facetattrs */
+#if 0
Z_Term *term_create(ODR odr, const char *cstr)
{
Z_Term *term = odr_malloc(odr, sizeof(*term));
*facet_term->count = freq;
return facet_term;
}
+#endif
+
+Z_FacetTerm *facet_term_create_cstr(ODR odr, const char *cstr, Odr_int freq)
+{
+ Z_FacetTerm *facet_term = odr_malloc(odr, sizeof(*facet_term));
+ Z_Term *term = z_Term_create(odr, Z_Term_general, cstr, strlen(cstr));
+ facet_term->term = term;
+ facet_term->count = odr_intdup(odr, freq);
+ return facet_term;
+}
Z_FacetField* facet_field_create(ODR odr, Z_AttributeList *attributes,
int num_terms)