X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fsolr.c;h=28b8f11b552e33bb3afb204c1f5a692069a77daa;hp=0fd1480ebd9ca754f3b8450dac4c09ed0a133b59;hb=2715f6522ca62ab5dbc886c21ed18945743216f0;hpb=34356a0306446525cc3b2a5ddc268d77e5ade288 diff --git a/src/solr.c b/src/solr.c index 0fd1480..28b8f11 100644 --- a/src/solr.c +++ b/src/solr.c @@ -4,7 +4,7 @@ */ /** * \file solr.c - * \brief Implements SOAP Webservice decoding/encoding + * \brief Implements Solr decoding/encoding */ #if HAVE_CONFIG_H #include @@ -59,8 +59,9 @@ static void yaz_solr_decode_result_docs(ODR o, xmlNodePtr ptr, for (node = ptr->children; node; node = node->next) if (node->type == XML_ELEMENT_NODE) sr->num_records++; - - sr->records = odr_malloc(o, sizeof(*sr->records) * sr->num_records); + + if (sr->num_records) + sr->records = odr_malloc(o, sizeof(*sr->records) * sr->num_records); for (node = ptr->children; node; node = node->next) { @@ -117,7 +118,7 @@ static int yaz_solr_decode_result(ODR o, xmlNodePtr ptr, return -1; } -static const char *get_facet_term_count(xmlNodePtr node, int *freq) +static const char *get_facet_term_count(xmlNodePtr node, Odr_int *freq) { const char *term = yaz_element_attribute_value_get(node, "int", "name"); xmlNodePtr child; @@ -130,7 +131,7 @@ static const char *get_facet_term_count(xmlNodePtr node, int *freq) if (child->type == XML_TEXT_NODE) wrbuf_puts(wrbuf, (const char *) child->content); } - *freq = atoi(wrbuf_cstr(wrbuf)); + *freq = odr_atoi(wrbuf_cstr(wrbuf)); wrbuf_destroy(wrbuf); return term; } @@ -153,11 +154,10 @@ Z_FacetField *yaz_solr_decode_facet_field(ODR o, xmlNodePtr ptr, index = 0; for (node = ptr->children; node; node = node->next) { - int count = 0; + Odr_int count = 0; const char *term = get_facet_term_count(node, &count); facet_field_term_set(o, facet_field, - facet_term_create(o, term_create(o, term), count), - index); + facet_term_create_cstr(o, term, count), index); index++; } return facet_field; @@ -356,7 +356,20 @@ int yaz_solr_encode_request(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu, } else return -1; - name[i] = 0; + + if (srw_pdu->extra_args) + { + Z_SRW_extra_arg *ea = srw_pdu->extra_args; + for (; ea && i < SOLR_MAX_PARAMETERS; ea = ea->next) + { + name[i] = ea->name; + value[i] = ea->value; + i++; + } + } + + name[i++] = 0; + yaz_array_to_uri(&uri_args, encode, name, value); hreq->method = "GET";