// return -1 on query error
// return -2 on limit error
int client_parse_query(struct client *cl, const char *query,
- facet_limits_t facet_limits)
+ facet_limits_t facet_limits, const char **error_msg)
{
struct session *se = client_get_session(cl);
struct conf_service *service = se->service;
ccl_qual_rm(&ccl_map);
if (!cn)
{
+ if (error_msg)
+ *error_msg = ccl_err_msg(cerror);
client_set_state(cl, Client_Error);
session_log(se, YLOG_WARN, "Client %s: Failed to parse CCL query '%s'",
client_get_id(cl),
session_log(se, YLOG_WARN, "Invalid PQF query for Client %s: %s",
client_get_id(cl), cl->pquery);
ret_value = -1;
+ *error_msg = "Invalid PQF after CCL to PQF conversion";
}
else
{
else
cl->cqlquery = make_cqlquery(cl, zquery);
if (!cl->cqlquery)
+ {
+ *error_msg = "Cannot convert PQF to Solr/CQL";
ret_value = -1;
+ }
else
session_log(se, YLOG_LOG, "Client %s native query: %s (%s)",
client_get_id(cl), cl->cqlquery, sru);
struct client *client_next_in_session(struct client *cl);
int client_parse_query(struct client *cl, const char *query,
- facet_limits_t facet_limits);
+ facet_limits_t facet_limits, const char **error_msg);
Odr_int client_get_hits(struct client *cl);
Odr_int client_get_approximation(struct client *cl);
int client_get_num_records(struct client *cl);
return "No error";
}
-static void error(struct http_response *rs,
- enum pazpar2_error_code code,
- const char *addinfo)
+static void error2(struct http_response *rs,
+ enum pazpar2_error_code code,
+ const char *addinfo, const char *addinfo2)
{
struct http_channel *c = rs->channel;
WRBUF text = wrbuf_alloc();
wrbuf_printf(text, HTTP_COMMAND_RESPONSE_PREFIX
"<error code=\"%d\" msg=\"%s\">", (int) code, msg);
if (addinfo)
+ {
wrbuf_xmlputs(text, addinfo);
+ if (addinfo2)
+ {
+ wrbuf_xmlputs(text, ": ");
+ wrbuf_xmlputs(text, addinfo2);
+ }
+ }
wrbuf_puts(text, "</error>");
yaz_log(YLOG_WARN, "HTTP %s %s%s%s", http_status,
http_send_response(c);
}
+static void error(struct http_response *rs,
+ enum pazpar2_error_code code,
+ const char *addinfo)
+{
+ return error2(rs, code, addinfo, 0);
+}
+
static void response_open_command(struct http_channel *c, const char *command)
{
wrbuf_rewind(c->wrbuf);
const char *rank = http_argbyname(rq, "rank");
enum pazpar2_error_code code;
const char *addinfo = 0;
+ const char *addinfo2 = 0;
struct reclist_sortparms *sp;
struct conf_service *service = 0;
}
code = session_search(s->psession, query, startrecs, maxrecs, filter, limit,
- &addinfo, sp, mergekey, rank);
+ &addinfo, &addinfo2, sp, mergekey, rank);
if (code)
{
- error(rs, code, addinfo);
+ error2(rs, code, addinfo, addinfo2);
release_session(c, s);
return;
}
const char *filter,
const char *limit,
const char **addinfo,
+ const char **addinfo2,
struct reclist_sortparms *sp,
const char *mergekey,
const char *rank)
if (prepare_map(se, client_get_database(cl)) < 0)
continue;
- parse_ret = client_parse_query(cl, query, se->facet_limits);
+ parse_ret = client_parse_query(cl, query, se->facet_limits, addinfo2);
if (parse_ret == -1)
no_failed_query++;
else if (parse_ret == -2)
const char *maxrecs,
const char *filter, const char *limit,
const char **addinfo,
+ const char **addinfo2,
struct reclist_sortparms *sort_parm,
const char *mergekey,
const char *rank);
<?xml version="1.0" encoding="UTF-8"?>
-<error code="3" msg="Malformed parameter value">query</error>
\ No newline at end of file
+<error code="3" msg="Malformed parameter value">query: Search word expected</error>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
-<error code="3" msg="Malformed parameter value">query</error>
\ No newline at end of file
+<error code="3" msg="Malformed parameter value">query: Invalid PQF after CCL to PQF conversion</error>
\ No newline at end of file