X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Ffacet.c;h=70927681740253fdb5aa9c777616c303ec2336e9;hp=a9a5625b0b761a4e8c890fb9f309a68723ca0296;hb=2715f6522ca62ab5dbc886c21ed18945743216f0;hpb=cc210c8334133d10df376ba1d914d34d96798e32 diff --git a/src/facet.c b/src/facet.c index a9a5625..7092768 100644 --- a/src/facet.c +++ b/src/facet.c @@ -17,6 +17,7 @@ #include #include #include +#include #include void yaz_oi_set_facetlist( @@ -111,25 +112,24 @@ static void useattr(Z_AttributeElement *ae, struct yaz_facet_attr *av) 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; } } @@ -138,7 +138,7 @@ static void relationattr(Z_AttributeElement *ae, struct yaz_facet_attr *av) 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) { @@ -151,7 +151,7 @@ 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 @@ -178,7 +178,7 @@ void yaz_facet_attr_get_z_attributes(const Z_AttributeList *attributes, } else if (*ae->attributeType == 2) { /* sortorder */ - relationattr(ae, av); + sortorderattr(ae, av); } else if (*ae->attributeType == 3) { /* limit */ @@ -200,6 +200,7 @@ void yaz_facet_attr_get_z_attributes(const Z_AttributeList *attributes, return; } /* facetattrs */ +#if 0 Z_Term *term_create(ODR odr, const char *cstr) { Z_Term *term = odr_malloc(odr, sizeof(*term)); @@ -216,6 +217,16 @@ Z_FacetTerm* facet_term_create(ODR odr, Z_Term *term, int freq) *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)