Rename yaz_use_attribute_create to zget_AttributeList_use_string
[yaz-moved-to-github.git] / src / solr.c
index 4c77e6f..c1c1bba 100644 (file)
@@ -18,6 +18,7 @@
 #include <yaz/log.h>
 #include <yaz/facet.h>
 #include <yaz/wrbuf.h>
+#include <yaz/proto.h>
 
 #include "sru-p.h"
 
@@ -153,7 +154,7 @@ Z_FacetField *yaz_solr_decode_facet_field(ODR o, xmlNodePtr ptr,
     xmlNodePtr node;
     // USE attribute
     const char* name = yaz_element_attribute_value_get(ptr, "lst", "name");
-    list = yaz_use_attribute_create(o, name);
+    list = zget_AttributeList_use_string(o, name);
     for (node = ptr->children; node; node = node->next)
         num_terms++;
     facet_field = facet_field_create(o, list, num_terms);
@@ -482,6 +483,7 @@ int yaz_solr_encode_request(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu,
     char *q;
     char *pos;
     char *cp;
+    const char *path_args = 0;
     int i = 0;
 
     z_HTTP_header_add_basic_auth(encode, &hreq->headers,
@@ -580,8 +582,17 @@ int yaz_solr_encode_request(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu,
 
     path = (char *)
         odr_malloc(encode, strlen(hreq->path) +
-                   strlen(uri_args) + strlen(solr_op) + 4);
+                   strlen(uri_args) + strlen(solr_op) + 5);
 
+    cp = strchr(hreq->path, '#');
+    if (cp)
+        *cp = '\0';
+    cp = strchr(hreq->path, '?');
+    if (cp)
+    {
+        *cp = '\0'; /* args in path */
+        path_args = cp + 1;
+    }
     strcpy(path, hreq->path);
     cp = strrchr(path, '/');
     if (cp)
@@ -592,6 +603,11 @@ int yaz_solr_encode_request(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu,
     strcat(path, "/");
     strcat(path, solr_op);
     strcat(path, "?");
+    if (path_args)
+    {
+        strcat(path, path_args);
+        strcat(path, "&");
+    }
     strcat(path, uri_args);
     hreq->path = path;