YAZ  5.34.0
solr.c
Go to the documentation of this file.
1 /* This file is part of the YAZ toolkit.
2  * Copyright (C) Index Data
3  * See the file LICENSE for details.
4  */
9 #if HAVE_CONFIG_H
10 #include <config.h>
11 #endif
12 
13 #include <stdlib.h>
14 #include <assert.h>
15 #include <yaz/srw.h>
16 #include <yaz/matchstr.h>
17 #include <yaz/yaz-iconv.h>
18 #include <yaz/log.h>
19 #include <yaz/facet.h>
20 #include <yaz/wrbuf.h>
21 #include <yaz/proto.h>
22 #include <yaz/nmem_xml.h>
23 
24 #include "sru-p.h"
25 
26 #if YAZ_HAVE_XML2
27 #include <libxml/parser.h>
28 #include <libxml/tree.h>
29 
30 static void extract_text_node(xmlNodePtr node, WRBUF wrbuf)
31 {
32  xmlNodePtr child;
33  for (child = node->children; child ; child = child->next)
34  if (child->type == XML_TEXT_NODE)
35  wrbuf_xmlputs(wrbuf, (const char *) child->content);
36 }
37 
39  xmlNodePtr ptr,
40  const char *node_name, const char *attribute_name, const char *value)
41 {
42  const char *attribute_value;
43  if (strcmp((const char*) ptr->name, node_name))
44  return 0;
45  if (attribute_name)
46  {
47  attribute_value = yaz_element_attribute_value_get(ptr, node_name,
48  attribute_name);
49  if (attribute_value && !strcmp(attribute_value, value))
50  return 1;
51  }
52  else /* No attribute to check */
53  return 1;
54  return 0;
55 }
56 
57 static void yaz_solr_decode_result_docs(ODR o, xmlNodePtr ptr,
58  Odr_int start,
60 {
61  xmlNodePtr node;
62  int offset = 0;
63  int i = 0;
64 
65  sr->num_records = 0;
66  for (node = ptr->children; node; node = node->next)
67  if (node->type == XML_ELEMENT_NODE)
68  sr->num_records++;
69 
70  if (sr->num_records)
71  sr->records = odr_malloc(o, sizeof(*sr->records) * sr->num_records);
72 
73  for (node = ptr->children; node; node = node->next)
74  {
75  if (node->type == XML_ELEMENT_NODE)
76  {
77  Z_SRW_record *record = sr->records + i;
78  xmlBufferPtr buf = xmlBufferCreate();
79  xmlNode *tmp = xmlCopyNode(node, 1);
80 
81  xmlNodeDump(buf, tmp->doc, tmp, 0, 0);
82 
83  xmlFreeNode(tmp);
84 
85  record->recordSchema = 0;
87  record->recordData_len = buf->use;
88  record->recordData_buf =
89  odr_strdupn(o, (const char *) buf->content, buf->use);
90  record->recordPosition = odr_intdup(o, start + offset + 1);
91 
92  xmlBufferFree(buf);
93 
94  offset++;
95  i++;
96  }
97  }
98 }
99 
100 static int yaz_solr_decode_result(ODR o, xmlNodePtr ptr,
102 {
103  Odr_int start = 0;
104  struct _xmlAttr *attr;
105  for (attr = ptr->properties; attr; attr = attr->next)
106  if (attr->children && attr->children->type == XML_TEXT_NODE)
107  {
108  if (!strcmp((const char *) attr->name, "numFound"))
109  {
111  (const char *) attr->children->content));
112  }
113  else if (!strcmp((const char *) attr->name, "start"))
114  {
115  start = odr_atoi((const char *) attr->children->content);
116  }
117  }
118  if (sr->numberOfRecords && *sr->numberOfRecords > 0)
119  yaz_solr_decode_result_docs(o, ptr, start, sr);
120  if (sr->numberOfRecords)
121  return 0;
122  return -1;
123 }
124 
125 static const char *get_facet_term_count(ODR o, xmlNodePtr node, Odr_int *freq)
126 {
127  const char *term = yaz_element_attribute_value_get(node, "int", "name");
128  if (!term)
129  return term;
130 
131  *freq = odr_atoi(nmem_text_node_cdata(node->children, odr_getmem(o)));
132  return term;
133 }
134 
137 
138 {
139  Z_AttributeList *list;
140  Z_FacetField *facet_field;
141  int num_terms = 0;
142  int index = 0;
143  xmlNodePtr node;
144  const char* name = yaz_element_attribute_value_get(ptr, "lst", "name");
145 
146  if (name == 0)
147  return 0;
149  for (node = ptr->children; node; node = node->next)
150  num_terms++;
151  facet_field = facet_field_create(o, list, num_terms);
152  index = 0;
153  for (node = ptr->children; node; node = node->next)
154  {
155  Odr_int count = 0;
156  const char *term = get_facet_term_count(o, node, &count);
157  if (term)
158  {
159  facet_field_term_set(o, facet_field,
160  facet_term_create_cstr(o, term, count), index);
161  index++;
162  }
163  }
164  facet_field->num_terms = index;
165  return facet_field;
166 }
167 
168 static int yaz_solr_decode_facet_counts(ODR o, xmlNodePtr root,
170 {
171  xmlNodePtr ptr;
172  for (ptr = root->children; ptr; ptr = ptr->next)
173  {
174  if (match_xml_node_attribute(ptr, "lst", "name", "facet_fields"))
175  {
176  xmlNodePtr node;
177  Z_FacetList *facet_list;
178  int num_facets = 0;
179  for (node = ptr->children; node; node= node->next)
180  num_facets++;
181  facet_list = facet_list_create(o, num_facets);
182  num_facets = 0;
183  for (node = ptr->children; node; node = node->next)
184  {
186  if (ff)
187  {
188  facet_list_field_set(o, facet_list, ff, num_facets);
189  num_facets++;
190  }
191  }
192  sr->facetList = facet_list;
193  sr->facetList->num = num_facets;
194  break;
195  }
196  }
197  return 0;
198 }
199 
200 static void yaz_solr_decode_suggestion_values(xmlNodePtr listPptr, WRBUF wrbuf)
201 {
202  xmlNodePtr node;
203  for (node = listPptr; node; node = node->next)
204  if (node->type == XML_ELEMENT_NODE
205  && !strcmp((const char*) node->name, "lst"))
206  {
207  xmlNodePtr child;
208  for (child = node->children; child; child= child->next)
209  {
210  if (match_xml_node_attribute(child, "str", "name", "word"))
211  {
212  wrbuf_puts(wrbuf, "<suggestion>");
213  extract_text_node(child, wrbuf);
214  wrbuf_puts(wrbuf, "</suggestion>\n");
215  }
216  }
217  }
218 }
219 
220 static void yaz_solr_decode_suggestion_lst(xmlNodePtr lstPtr, WRBUF wrbuf)
221 {
222  xmlNodePtr node;
223  for (node = lstPtr; node; node = node->next)
224  if (match_xml_node_attribute(node, "arr", "name", "suggestion"))
226 }
227 
228 static void yaz_solr_decode_misspelled(xmlNodePtr lstPtr, WRBUF wrbuf)
229 {
230  xmlNodePtr node;
231  for (node = lstPtr; node; node= node->next)
232  {
233  if (node->type == XML_ELEMENT_NODE)
234  {
235  const char *misspelled =
236  yaz_element_attribute_value_get(node, "lst", "name");
237  if (misspelled)
238  {
239  wrbuf_printf(wrbuf, "<misspelled term=\"");
240  wrbuf_xmlputs(wrbuf, misspelled);
241  wrbuf_printf(wrbuf, "\">\n");
243  wrbuf_puts(wrbuf, "</misspelled>\n");
244  }
245  }
246  }
247 }
248 
249 static int yaz_solr_decode_spellcheck(ODR o, xmlNodePtr spellcheckPtr,
251 {
252  xmlNodePtr ptr;
253  WRBUF wrbuf = wrbuf_alloc();
254  for (ptr = spellcheckPtr->children; ptr; ptr = ptr->next)
255  if (match_xml_node_attribute(ptr, "lst", "name", "suggestions"))
256  yaz_solr_decode_misspelled(ptr->children, wrbuf);
259  return 0;
260 }
261 
262 static int yaz_solr_decode_scan_result(ODR o, xmlNodePtr ptr,
263  Z_SRW_scanResponse *scr)
264 {
265  xmlNodePtr node;
266  char *pos;
267  int i = 0;
268 
269  /* find the actual list */
270  for (node = ptr->children; node; node = node->next)
271  if (node->type == XML_ELEMENT_NODE)
272  {
273  ptr = node;
274  break;
275  }
276 
277  scr->num_terms = 0;
278  for (node = ptr->children; node; node = node->next)
279  if (node->type == XML_ELEMENT_NODE &&
280  !strcmp((const char *) node->name, "int"))
281  scr->num_terms++;
282 
283  if (scr->num_terms)
284  scr->terms = odr_malloc(o, sizeof(*scr->terms) * scr->num_terms);
285 
286  for (node = ptr->children; node; node = node->next)
287  {
288  if (node->type == XML_ELEMENT_NODE &&
289  !strcmp((const char *) node->name, "int"))
290  {
291  Z_SRW_scanTerm *term = scr->terms + i;
292 
293  Odr_int count = 0;
294  const char *val = get_facet_term_count(o, node, &count);
295 
296  term->numberOfRecords = odr_intdup(o, count);
297 
298  /* if val contains a ^ then it is probably term<^>display term so separate them.
299  * This is due to SOLR not being able to encode them into 2 separate attributes.
300  */
301  pos = strchr(val, '^');
302  if (pos != NULL)
303  {
304  term->displayTerm = odr_strdup(o, pos + 1);
305  *pos = '\0';
306  term->value = odr_strdup(o, val);
307  *pos = '^';
308  }
309  else
310  {
311  term->value = odr_strdup(o, val);
312  term->displayTerm = NULL;
313  }
314  term->whereInList = NULL;
315  i++;
316  }
317  }
318 
319  if (scr->num_terms)
320  return 0;
321  return -1;
322 }
323 
324 static int yaz_solr_decode_error(ODR o, xmlNode *ptr,
326 {
327  for (ptr = ptr->children; ptr; ptr = ptr->next)
328  if (ptr->type == XML_ELEMENT_NODE &&
329  match_xml_node_attribute(ptr, "str", "name", "msg"))
330  {
331  char *msg = nmem_text_node_cdata(ptr->children, odr_getmem(o));
334  }
335  return 0;
336 }
337 
338 #endif
339 
341 {
342  int ret = -1;
343  Z_SRW_PDU *pdu = 0;
344 #if YAZ_HAVE_XML2
345  const char *content_buf = hres->content_buf;
346  int content_len = hres->content_len;
347  xmlDocPtr doc = xmlParseMemory(content_buf, content_len);
348 
349  if (doc)
350  {
351  Z_SRW_searchRetrieveResponse *sr = NULL;
352  Z_SRW_scanResponse *scr = NULL;
353  xmlNodePtr ptr;
354  xmlNodePtr root = xmlDocGetRootElement(doc);
355  if (root && !strcmp((const char *) root->name, "response"))
356  {
357  for (ptr = root->children; ptr; ptr = ptr->next)
358  {
359  if (!pdu && ptr->type == XML_ELEMENT_NODE &&
360  match_xml_node_attribute(ptr, "lst", "name", "error"))
361  {
363  sr = pdu->u.response;
364  ret = yaz_solr_decode_error(o, ptr, sr);
365  }
366  if (ptr->type == XML_ELEMENT_NODE &&
367  !strcmp((const char *) ptr->name, "result"))
368  {
370  sr = pdu->u.response;
371  ret = yaz_solr_decode_result(o, ptr, sr);
372  }
373  if (ptr->type == XML_ELEMENT_NODE &&
374  match_xml_node_attribute(ptr, "lst", "name", "terms"))
375  {
377  scr = pdu->u.scan_response;
378  ret = yaz_solr_decode_scan_result(o, ptr, scr);
379  }
380  /* The check on hits is a work-around to avoid garbled
381  facets on zero results from the SOLR server.
382  The work-around works because the results is before
383  the facets in the xml.
384  */
385  if (sr && sr->numberOfRecords)
386  {
387  if (*sr->numberOfRecords > 0 &&
388  match_xml_node_attribute(ptr, "lst", "name",
389  "facet_counts"))
390  ret = yaz_solr_decode_facet_counts(o, ptr, sr);
391  if (*sr->numberOfRecords == 0 &&
392  match_xml_node_attribute(ptr, "lst", "name",
393  "spellcheck"))
394  ret = yaz_solr_decode_spellcheck(o, ptr, sr);
395  }
396  }
397  }
398  xmlFreeDoc(doc);
399  }
400 #endif
401  *pdup = pdu;
402  return ret;
403 }
404 
406  ODR encode, char **name, char **value, int *i,
407  Z_FacetField *facet_field)
408 {
409  Z_AttributeList *attribute_list = facet_field->attributes;
410  struct yaz_facet_attr attr_values;
411  yaz_facet_attr_init(&attr_values);
412  yaz_facet_attr_get_z_attributes(attribute_list, &attr_values);
413 
414  if (attr_values.errcode)
415  return -1;
416  if (attr_values.useattr)
417  {
418  WRBUF wrbuf = wrbuf_alloc();
419  yaz_add_name_value_str(encode, name, value, i,
420  "facet.field",
421  odr_strdup(encode, attr_values.useattr));
422 
423  if (attr_values.limit > 0)
424  {
425  Odr_int v = attr_values.limit;
427  wrbuf_printf(wrbuf, "f.%s.facet.limit", attr_values.useattr);
428  yaz_add_name_value_int(encode, name, value, i,
429  odr_strdup(encode, wrbuf_cstr(wrbuf)),
430  &v);
431  }
432  if (attr_values.start > 1)
433  {
434  Odr_int v = attr_values.start - 1;
436  wrbuf_printf(wrbuf, "f.%s.facet.offset", attr_values.useattr);
437  yaz_add_name_value_int(encode, name, value, i,
438  odr_strdup(encode, wrbuf_cstr(wrbuf)),
439  &v);
440  }
441  if (attr_values.sortorder == 1)
442  {
444  wrbuf_printf(wrbuf, "f.%s.facet.sort", attr_values.useattr);
445  yaz_add_name_value_str(encode, name, value, i,
446  odr_strdup(encode, wrbuf_cstr(wrbuf)),
447  "index");
448  }
450  }
451  else
452  {
453  if (attr_values.limit > 0)
454  {
455  Odr_int v = attr_values.limit;
456  yaz_add_name_value_int(encode, name, value, i, "facet.limit", &v);
457  }
458  if (attr_values.start > 1)
459  {
460  Odr_int v = attr_values.start - 1;
461  yaz_add_name_value_int(encode, name, value, i, "facet.offset", &v);
462  }
463  if (attr_values.sortorder == 1)
464  {
465  yaz_add_name_value_str(encode, name, value, i, "facet.sort",
466  "index");
467  }
468  }
469  return 0;
470 }
471 
473  ODR encode, char **name, char **value,
474  int *i, Z_FacetList *facet_list)
475 {
476  int index;
477  for (index = 0; index < facet_list->num; index++)
478  {
479  int r = yaz_solr_encode_facet_field(encode, name, value, i,
480  facet_list->elements[index]);
481  if (r)
482  return -1;
483 
484  }
485  return 0;
486 }
487 
489  ODR encode, const char *charset)
490 {
491  const char *solr_op = 0;
492  char **name, **value;
493  char *uri_args;
494  char *path;
495  char *q;
496  char *cp;
497  int i = 0;
498  int defType_set = 0;
499  int no_parms = 20; /* safe upper limit of args without extra_args */
500  Z_SRW_extra_arg *ea;
501 
502  if (srw_pdu->which == Z_SRW_searchRetrieve_request)
503  { /* to make room for facets in yaz_solr_encode_facet_list later */
505  if (request->facetList)
506  no_parms += request->facetList->num;
507  }
508  for (ea = srw_pdu->extra_args; ea; ea = ea->next)
509  no_parms++;
510  name = (char **) odr_malloc(encode, sizeof(*name) * no_parms);
511  value = (char **) odr_malloc(encode, sizeof(*value) * no_parms);
512 
513  for (ea = srw_pdu->extra_args; ea; ea = ea->next)
514  {
515  name[i] = ea->name;
516  if (!strcmp(ea->name, "defType"))
517  defType_set = 1;
518  value[i] = ea->value;
519  i++;
520  }
521 
522  z_HTTP_header_add_basic_auth(encode, &hreq->headers,
523  srw_pdu->username, srw_pdu->password);
524  if (srw_pdu->which == Z_SRW_searchRetrieve_request)
525  {
527  solr_op = "select";
528  if (!srw_pdu->u.request->query)
529  return -1;
530  if (!defType_set)
531  yaz_add_name_value_str(encode, name, value, &i, "defType",
532  "lucene");
533  yaz_add_name_value_str(encode, name, value, &i, "q", request->query);
534  if (srw_pdu->u.request->startRecord)
535  {
536  Odr_int start = *request->startRecord - 1;
537  yaz_add_name_value_int(encode, name, value, &i,
538  "start", &start);
539  }
540  yaz_add_name_value_int(encode, name, value, &i,
541  "rows", request->maximumRecords);
542  yaz_add_name_value_str(encode, name, value, &i,
543  "fl", request->recordSchema);
544 
545  switch(srw_pdu->u.request->sort_type)
546  {
548  break;
550  yaz_add_name_value_str(encode, name, value, &i, "sort",
551  srw_pdu->u.request->sort.sortKeys);
552  break;
553  }
554  if (request->facetList)
555  {
556  Z_FacetList *facet_list = request->facetList;
557  yaz_add_name_value_str(encode, name, value, &i, "facet", "true");
558  yaz_add_name_value_str(encode, name, value, &i, "facet.mincount", "1");
559  if (yaz_solr_encode_facet_list(encode, name, value, &i, facet_list))
560  return -1;
561  }
562  }
563  else if (srw_pdu->which == Z_SRW_scan_request)
564  {
566  solr_op = "terms";
567  if (!srw_pdu->u.scan_request->scanClause)
568  return -1;
569  if (!strcmp(srw_pdu->u.scan_request->queryType, "pqf"))
570  {
571  yaz_add_name_value_str(encode, name, value, &i,
572  "terms.fl", request->scanClause);
573  yaz_add_name_value_str(encode, name, value, &i,
574  "terms.lower", request->scanClause);
575  }
576  else if (!strcmp(srw_pdu->u.scan_request->queryType, "cql"))
577  {
578  q = request->scanClause;
579  cp = strchr(q, ':');
580  if (cp != NULL)
581  {
582  yaz_add_name_value_str(encode, name, value, &i,
583  "terms.lower", odr_strdup(encode, cp + 1));
584  *cp = '\0';
585  yaz_add_name_value_str(encode, name, value, &i,
586  "terms.fl", odr_strdup(encode, q));
587  *cp = ':';
588  }
589  else
590  yaz_add_name_value_str(encode, name, value, &i,
591  "terms.lower", odr_strdup(encode, q));
592  }
593  else
594  return -1;
595  yaz_add_name_value_str(encode, name, value, &i,
596  "terms.sort", "index");
597  yaz_add_name_value_int(encode, name, value, &i,
598  "terms.limit", request->maximumTerms);
599  }
600  else
601  return -1;
602 
603  name[i++] = 0;
604 
605  yaz_array_to_uri(&uri_args, encode, name, value);
606 
607  hreq->method = "GET";
608 
609  path = (char *)
610  odr_malloc(encode, strlen(hreq->path) +
611  strlen(uri_args) + strlen(solr_op) + 5);
612 
613  cp = strchr(hreq->path, '#');
614  if (cp)
615  *cp = '\0';
616  strcpy(path, hreq->path);
617  cp = strchr(path, '?');
618  if (cp && strcmp(solr_op, "terms"))
619  { /* complete path with requestHandler */
620  int last = path[strlen(path)-1];
621  if (last != '?' && last != '&')
622  strcat(path, "&");
623  }
624  else
625  {
626  /* add requestHandler ourselves */
627  cp = strrchr(path, '/');
628  if (cp)
629  {
630  if (!strcmp(cp, "/select") || !strcmp(cp, "/"))
631  *cp = '\0';
632  }
633  strcat(path, "/");
634  strcat(path, solr_op);
635  strcat(path, "?");
636  }
637  strcat(path, uri_args);
638  hreq->path = path;
639  return 0;
640 }
641 
642 
643 /*
644  * Local variables:
645  * c-basic-offset: 4
646  * c-file-style: "Stroustrup"
647  * indent-tabs-mode: nil
648  * End:
649  * vim: shiftwidth=4 tabstop=8 expandtab
650  */
651 
static int node(struct cql_node *cn, void(*pr)(const char *buf, void *client_data), void *client_data)
Definition: cql2ccl.c:86
#define YAZ_SRW_UNSUPP_PARAMETER_VALUE
Definition: diagsrw.h:15
Z_FacetField * facet_field_create(ODR odr, Z_AttributeList *attributes, int num_terms)
Definition: facet.c:198
Z_FacetTerm * facet_term_create_cstr(ODR odr, const char *cstr, Odr_int freq)
Definition: facet.c:189
Z_FacetList * facet_list_create(ODR odr, int num_facets)
Definition: facet.c:215
void facet_field_term_set(ODR odr, Z_FacetField *field, Z_FacetTerm *facet_term, int index)
Definition: facet.c:208
void yaz_facet_attr_init(struct yaz_facet_attr *attr_values)
Definition: facet.c:68
void facet_list_field_set(ODR odr, Z_FacetList *list, Z_FacetField *field, int index)
Definition: facet.c:224
void yaz_facet_attr_get_z_attributes(const Z_AttributeList *attributes, struct yaz_facet_attr *av)
Definition: facet.c:147
Header for the facet utilities.
void z_HTTP_header_add_basic_auth(ODR o, Z_HTTP_Header **hp, const char *username, const char *password)
Definition: http.c:168
char * name
Definition: initopt.c:18
Logging utility.
Header for YAZ iconv interface.
Header for Nibble Memory functions + Libxml2 specific stuff.
char * nmem_text_node_cdata(const xmlNode *ptr_cdata, NMEM nmem)
copies TEXT Libxml2 node data to NMEM
Definition: nmemsdup.c:145
#define odr_getmem(o)
Definition: odr.h:216
nmem_int_t Odr_int
Definition: odr.h:47
char * odr_strdupn(ODR o, const char *str, size_t n)
Definition: odr_mem.c:46
Odr_int odr_atoi(const char *s)
Definition: odr_mem.c:146
char * odr_strdup(ODR o, const char *str)
Definition: odr_mem.c:36
Odr_int * odr_intdup(ODR o, Odr_int v)
Definition: odr_mem.c:51
void * odr_malloc(ODR o, size_t size)
Definition: odr_mem.c:31
Z_AttributeList * zget_AttributeList_use_string(ODR o, const char *name)
creates AttributeList with type=1(use) and string value
Definition: pquery.c:310
Header for Z39.50 Protocol.
static void extract_text_node(xmlNodePtr node, WRBUF wrbuf)
Definition: solr.c:30
static int yaz_solr_encode_facet_field(ODR encode, char **name, char **value, int *i, Z_FacetField *facet_field)
Definition: solr.c:405
static void yaz_solr_decode_result_docs(ODR o, xmlNodePtr ptr, Odr_int start, Z_SRW_searchRetrieveResponse *sr)
Definition: solr.c:57
static void yaz_solr_decode_suggestion_lst(xmlNodePtr lstPtr, WRBUF wrbuf)
Definition: solr.c:220
int yaz_solr_encode_request(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu, ODR encode, const char *charset)
encode SOLR request (HTTP)
Definition: solr.c:488
static int match_xml_node_attribute(xmlNodePtr ptr, const char *node_name, const char *attribute_name, const char *value)
Definition: solr.c:38
static void yaz_solr_decode_suggestion_values(xmlNodePtr listPptr, WRBUF wrbuf)
Definition: solr.c:200
static const char * get_facet_term_count(ODR o, xmlNodePtr node, Odr_int *freq)
Definition: solr.c:125
static int yaz_solr_decode_spellcheck(ODR o, xmlNodePtr spellcheckPtr, Z_SRW_searchRetrieveResponse *sr)
Definition: solr.c:249
static int yaz_solr_decode_facet_counts(ODR o, xmlNodePtr root, Z_SRW_searchRetrieveResponse *sr)
Definition: solr.c:168
static int yaz_solr_encode_facet_list(ODR encode, char **name, char **value, int *i, Z_FacetList *facet_list)
Definition: solr.c:472
static int yaz_solr_decode_scan_result(ODR o, xmlNodePtr ptr, Z_SRW_scanResponse *scr)
Definition: solr.c:262
int yaz_solr_decode_response(ODR o, Z_HTTP_Response *hres, Z_SRW_PDU **pdup)
decode SOLR response (HTTP)
Definition: solr.c:340
static void yaz_solr_decode_misspelled(xmlNodePtr lstPtr, WRBUF wrbuf)
Definition: solr.c:228
static int yaz_solr_decode_result(ODR o, xmlNodePtr ptr, Z_SRW_searchRetrieveResponse *sr)
Definition: solr.c:100
Z_FacetField * yaz_solr_decode_facet_field(ODR o, xmlNodePtr ptr, Z_SRW_searchRetrieveResponse *sr)
Definition: solr.c:135
static int yaz_solr_decode_error(ODR o, xmlNode *ptr, Z_SRW_searchRetrieveResponse *sr)
Definition: solr.c:324
SRU private header.
void yaz_add_name_value_int(ODR o, char **name, char **value, int *i, char *a_name, Odr_int *val)
Definition: srwutil.c:927
const char * yaz_element_attribute_value_get(xmlNodePtr ptr, const char *node_name, const char *attribute_name)
Definition: srwutil.c:71
void yaz_add_name_value_str(ODR o, char **name, char **value, int *i, char *a_name, char *val)
Definition: srwutil.c:939
Header for SRW/SRU.
#define Z_SRW_recordPacking_XML
Definition: srw.h:55
#define Z_SRW_searchRetrieve_response
Definition: srw.h:192
#define Z_SRW_scan_request
Definition: srw.h:195
#define Z_SRW_sort_type_none
Definition: srw.h:74
#define Z_SRW_sort_type_sort
Definition: srw.h:75
#define Z_SRW_scan_response
Definition: srw.h:196
#define Z_SRW_searchRetrieve_request
Definition: srw.h:191
Z_SRW_PDU * yaz_srw_get(ODR o, int which)
Definition: srwutil.c:755
void yaz_add_srw_diagnostic(ODR o, Z_SRW_diagnostic **d, int *num, int code, const char *addinfo)
Definition: srwutil.c:183
int num_terms
Definition: z-facet-1.h:37
Z_AttributeList * attributes
Definition: z-facet-1.h:36
Z_FacetField ** elements
Definition: z-facet-1.h:32
Z_HTTP_Header * headers
Definition: zgdu.h:52
char * path
Definition: zgdu.h:51
char * method
Definition: zgdu.h:49
char * content_buf
Definition: zgdu.h:61
int content_len
Definition: zgdu.h:62
Definition: srw.h:200
union Z_SRW_PDU::@30 u
Z_SRW_scanRequest * scan_request
Definition: srw.h:207
Z_SRW_searchRetrieveResponse * response
Definition: srw.h:204
Z_SRW_extra_arg * extra_args
Definition: srw.h:219
Z_SRW_scanResponse * scan_response
Definition: srw.h:208
Z_SRW_searchRetrieveRequest * request
Definition: srw.h:203
char * password
Definition: srw.h:214
int which
Definition: srw.h:201
char * username
Definition: srw.h:213
char * value
Definition: srw.h:174
Z_SRW_extra_arg * next
Definition: srw.h:175
char * name
Definition: srw.h:173
char * recordData_buf
Definition: srw.h:58
int recordPacking
Definition: srw.h:53
char * recordSchema
Definition: srw.h:51
int recordData_len
Definition: srw.h:59
Odr_int * recordPosition
Definition: srw.h:60
char * queryType
Definition: srw.h:130
char * scanClause
Definition: srw.h:131
Z_SRW_scanTerm * terms
Definition: srw.h:146
char * displayTerm
Definition: srw.h:141
char * whereInList
Definition: srw.h:142
Odr_int * numberOfRecords
Definition: srw.h:140
char * value
Definition: srw.h:139
Odr_int * startRecord
Definition: srw.h:83
union Z_SRW_searchRetrieveRequest::@29 sort
Z_SRW_record * records
Definition: srw.h:103
Odr_int * numberOfRecords
Definition: srw.h:98
Z_SRW_diagnostic * diagnostics
Definition: srw.h:106
Z_FacetList * facetList
Definition: srw.h:111
Definition: odr.h:125
string buffer
Definition: wrbuf.h:43
int start
Definition: facet.h:62
int sortorder
Definition: facet.h:60
int limit
Definition: facet.h:61
const char * useattr
Definition: facet.h:56
int errcode
Definition: facet.h:54
void yaz_array_to_uri(char **path, ODR o, char **name, char **value)
Definition: uri.c:98
void wrbuf_destroy(WRBUF b)
destroy WRBUF and its buffer
Definition: wrbuf.c:38
void wrbuf_rewind(WRBUF b)
empty WRBUF content (length of buffer set to 0)
Definition: wrbuf.c:47
WRBUF wrbuf_alloc(void)
construct WRBUF
Definition: wrbuf.c:25
void wrbuf_printf(WRBUF b, const char *fmt,...)
writes printf result to WRBUF
Definition: wrbuf.c:178
void wrbuf_xmlputs(WRBUF b, const char *cp)
writes C-String to WRBUF and XML encode (as CDATA)
Definition: wrbuf.c:138
const char * wrbuf_cstr(WRBUF b)
returns WRBUF content as C-string
Definition: wrbuf.c:281
void wrbuf_puts(WRBUF b, const char *buf)
appends C-string to WRBUF
Definition: wrbuf.c:89
Header for WRBUF (growing buffer)
Header for YAZ iconv interface.