X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fzoom-sru.c;h=557e812254f1385a04a15e19619190c9ebb42fd6;hp=57f02a38d8f449d2ac958c353d2fbcf2befcb02d;hb=4849119cd60244ee5ed16958e885bc97315d23ad;hpb=2b33c56ec97fff11e300f441c88a61e04a176f68 diff --git a/src/zoom-sru.c b/src/zoom-sru.c index 57f02a3..557e812 100644 --- a/src/zoom-sru.c +++ b/src/zoom-sru.c @@ -1,11 +1,14 @@ /* This file is part of the YAZ toolkit. - * Copyright (C) 1995-2010 Index Data + * Copyright (C) 1995-2011 Index Data * See the file LICENSE for details. */ /** * \file zoom-sru.c * \brief Implements ZOOM SRU */ +#if HAVE_CONFIG_H +#include +#endif #include #include @@ -13,6 +16,9 @@ #include "zoom-p.h" #include +#include + +void handle_facet_list(ZOOM_resultset r, Z_FacetList *fl); #if YAZ_HAVE_XML2 static void set_SRU_error(ZOOM_connection c, Z_SRW_diagnostic *d) @@ -132,13 +138,14 @@ zoom_ret ZOOM_connection_srw_send_scan(ZOOM_connection c) #if YAZ_HAVE_XML2 zoom_ret ZOOM_connection_srw_send_search(ZOOM_connection c) { + const char *facets = 0; int i; int *start, *count; ZOOM_resultset resultset = 0; Z_SRW_PDU *sr = 0; const char *option_val = 0; Z_Query *z_query; - + Z_FacetList *facet_list = 0; if (c->error) /* don't continue on error */ return zoom_complete; assert(c->tasks); @@ -151,6 +158,9 @@ zoom_ret ZOOM_connection_srw_send_search(ZOOM_connection c) ZOOM_options_set(resultset->options, "setname", resultset->setname); start = &c->tasks->u.search.start; count = &c->tasks->u.search.count; + facets = ZOOM_options_get(resultset->options, "facets"); + if (facets) + facet_list = yaz_pqf_parse_facet_list(c->odr_out, facets); break; case ZOOM_TASK_RETRIEVE: resultset = c->tasks->u.retrieve.resultset; @@ -213,6 +223,7 @@ zoom_ret ZOOM_connection_srw_send_search(ZOOM_connection c) c->odr_out, (resultset->step > 0 && resultset->step < *count) ? resultset->step : *count); sr->u.request->recordSchema = resultset->schema; + sr->u.request->facetList = facet_list; option_val = ZOOM_resultset_option_get(resultset, "recordPacking"); if (option_val) @@ -252,12 +263,15 @@ static zoom_ret handle_srw_response(ZOOM_connection c, syntax = c->tasks->u.search.syntax; elementSetName = c->tasks->u.search.elementSetName; - if (!c->tasks->u.search.recv_search_fired) - { + /* Required not for reporting client hit count multiple times into session */ + if (!c->tasks->u.search.recv_search_fired) { + yaz_log(YLOG_DEBUG, "posting ZOOM_EVENT_RECV_SEARCH"); event = ZOOM_Event_create(ZOOM_EVENT_RECV_SEARCH); ZOOM_connection_put_event(c, event); c->tasks->u.search.recv_search_fired = 1; } + if (res->facetList) + handle_facet_list(resultset, res->facetList); break; case ZOOM_TASK_RETRIEVE: resultset = c->tasks->u.retrieve.resultset; @@ -380,6 +394,7 @@ static void handle_srw_scan_response(ZOOM_connection c, int ZOOM_handle_sru(ZOOM_connection c, Z_HTTP_Response *hres, zoom_ret *cret) { +#if YAZ_HAVE_XML2 int ret = 0; const char *addinfo = 0; @@ -434,6 +449,9 @@ int ZOOM_handle_sru(ZOOM_connection c, Z_HTTP_Response *hres, ret = -1; } return ret; +#else + return -1; +#endif } /*