X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=src%2Fclient.c;fp=src%2Fclient.c;h=cb5088d249e350fec4fff0ac17233acfbabee125;hb=4dff82b21feb6db92443026561d106691ad29ee0;hp=6a7f6a41bbd362a48f4f2c9c0230892a34fdb845;hpb=5410847495fb43bdc5c3e630fbc3f15a964640f9;p=pazpar2-moved-to-github.git diff --git a/src/client.c b/src/client.c index 6a7f6a4..cb5088d 100644 --- a/src/client.c +++ b/src/client.c @@ -841,6 +841,34 @@ static char *make_cqlquery(struct client *cl) return r; } +// returns a xmalloced SOLR query corresponding to the pquery in client +// TODO Could prob. be merge with the similar make_cqlquery +static char *make_solrquery(struct client *cl) +{ + cql_transform_t sqlt = solr_transform_create(); + Z_RPNQuery *zquery; + char *r; + WRBUF wrb = wrbuf_alloc(); + int status; + ODR odr_out = odr_createmem(ODR_ENCODE); + + zquery = p_query_rpn(odr_out, cl->pquery); + yaz_log(YLOG_LOG, "PQF: %s", cl->pquery); + if ((status = solr_transform_rpn2solr_wrbuf(sqlt, wrb, zquery))) + { + yaz_log(YLOG_WARN, "Failed to generate SOLR query, code=%d", status); + r = 0; + } + else + { + r = xstrdup(wrbuf_cstr(wrb)); + } + wrbuf_destroy(wrb); + odr_destroy(odr_out); + cql_transform_close(sqlt); + return r; +} + // Parse the query given the settings specific to this client int client_parse_query(struct client *cl, const char *query) { @@ -898,6 +926,8 @@ int client_parse_query(struct client *cl, const char *query) xfree(cl->cqlquery); if (*sru) { + if (!strcmp(sru, "solr") + if (!(cl->cqlquery = make_cqlquery(cl))) return -1; }