projects
/
yaz-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
rpn2solr: solr_transform_set_error in main handler
[yaz-moved-to-github.git]
/
src
/
rpn2solr.c
diff --git
a/src/rpn2solr.c
b/src/rpn2solr.c
index
8006847
..
332ae88
100644
(file)
--- a/
src/rpn2solr.c
+++ b/
src/rpn2solr.c
@@
-1,5
+1,5
@@
/* This file is part of the YAZ toolkit.
/* This file is part of the YAZ toolkit.
- * Copyright (C) 1995-2013 Index Data
+ * Copyright (C) Index Data
* See the file LICENSE for details.
*/
/**
* See the file LICENSE for details.
*/
/**
@@
-19,11
+19,6
@@
#include <yaz/z-core.h>
#include <yaz/wrbuf.h>
#include <yaz/z-core.h>
#include <yaz/wrbuf.h>
-static void wrbuf_vputs(const char *buf, void *client_data)
-{
- wrbuf_write((WRBUF) client_data, buf, strlen(buf));
-}
-
static const char *lookup_index_from_string_attr(Z_AttributeList *attributes)
{
int j;
static const char *lookup_index_from_string_attr(Z_AttributeList *attributes)
{
int j;
@@
-158,15
+153,11
@@
static int rpn2solr_attr(solr_transform_t ct,
const char *index = solr_lookup_reverse(ct, "index.", attributes);
const char *structure = solr_lookup_reverse(ct, "structure.", attributes);
const char *index = solr_lookup_reverse(ct, "index.", attributes);
const char *structure = solr_lookup_reverse(ct, "structure.", attributes);
- /* if transform (properties) do not match, we'll just use a USE string attribute (bug #2978) */
+ /* if no real match, try string attribute */
if (!index)
index = lookup_index_from_string_attr(attributes);
if (!index)
if (!index)
index = lookup_index_from_string_attr(attributes);
if (!index)
- {
- solr_transform_set_error(ct,
- YAZ_BIB1_UNSUPP_USE_ATTRIBUTE, 0);
- return -1;
- }
+ return YAZ_BIB1_UNSUPP_USE_ATTRIBUTE;
/* for serverChoice we omit index+relation+structure */
if (strcmp(index, "cql.serverChoice"))
{
/* for serverChoice we omit index+relation+structure */
if (strcmp(index, "cql.serverChoice"))
{
@@
-229,9
+220,9
@@
static int emit_term(solr_transform_t ct, WRBUF w, Z_Term *term, Odr_int trunc)
lterm = strlen(sterm);
break;
default:
lterm = strlen(sterm);
break;
default:
- solr_transform_set_error(ct, YAZ_BIB1_TERM_TYPE_UNSUPP, 0);
- return -1;
+ return YAZ_BIB1_TERM_TYPE_UNSUPP;
}
}
+
if (sterm)
{
size_t i;
if (sterm)
{
size_t i;
@@
-242,6
+233,8
@@
static int emit_term(solr_transform_t ct, WRBUF w, Z_Term *term, Odr_int trunc)
must_quote = 1;
if (must_quote)
wrbuf_puts(w, "\"");
must_quote = 1;
if (must_quote)
wrbuf_puts(w, "\"");
+ if (trunc == 2 || trunc == 3)
+ wrbuf_puts(w, "*");
for (i = 0 ; i < lterm; i++)
{
if (sterm[i] == '\\' && i < lterm - 1)
for (i = 0 ; i < lterm; i++)
{
if (sterm[i] == '\\' && i < lterm - 1)
@@
-267,7
+260,7
@@
static int emit_term(solr_transform_t ct, WRBUF w, Z_Term *term, Odr_int trunc)
else
wrbuf_putc(w, sterm[i]);
}
else
wrbuf_putc(w, sterm[i]);
}
- if (trunc == 1)
+ if (trunc == 1 || trunc == 3)
wrbuf_puts(w, "*");
if (must_quote)
wrbuf_puts(w, "\"");
wrbuf_puts(w, "*");
if (must_quote)
wrbuf_puts(w, "\"");
@@
-292,8
+285,7
@@
static int rpn2solr_simple(solr_transform_t ct,
relation1 = lookup_relation_index_from_attr(apt->attributes);
if (!relation1)
{
relation1 = lookup_relation_index_from_attr(apt->attributes);
if (!relation1)
{
- solr_transform_set_error(ct, YAZ_BIB1_UNSUPP_RELATION_ATTRIBUTE, 0);
- return -1;
+ return YAZ_BIB1_UNSUPP_RELATION_ATTRIBUTE;
}
if (apt2)
{
}
if (apt2)
{
@@
-306,12
+298,11
@@
static int rpn2solr_simple(solr_transform_t ct,
ret = rpn2solr_attr(ct, apt->attributes, w);
if (ret)
return ret;
ret = rpn2solr_attr(ct, apt->attributes, w);
if (ret)
return ret;
- if (trunc == 0 || trunc == 1 || trunc == 100 || trunc == 104)
+ if ((trunc >= 0 && trunc <= 3) || trunc == 100 || trunc == 104)
;
else
{
;
else
{
- solr_transform_set_error(ct, YAZ_BIB1_UNSUPP_TRUNCATION_ATTRIBUTE, 0);
- return -1;
+ return YAZ_BIB1_UNSUPP_TRUNCATION_ATTRIBUTE;
}
if (!relation1)
}
if (!relation1)
@@
-355,18
+346,14
@@
static int rpn2solr_simple(solr_transform_t ct,
static int rpn2solr_structure(solr_transform_t ct,
void (*pr)(const char *buf, void *client_data),
static int rpn2solr_structure(solr_transform_t ct,
void (*pr)(const char *buf, void *client_data),
- void *client_data,
+ void *client_data,
Z_RPNStructure *q, int nested,
WRBUF w)
{
if (q->which == Z_RPNStructure_simple)
{
if (q->u.simple->which != Z_Operand_APT)
Z_RPNStructure *q, int nested,
WRBUF w)
{
if (q->which == Z_RPNStructure_simple)
{
if (q->u.simple->which != Z_Operand_APT)
- {
- solr_transform_set_error(
- ct, YAZ_BIB1_RESULT_SET_UNSUPP_AS_A_SEARCH_TERM, 0);
- return -1;
- }
+ return YAZ_BIB1_RESULT_SET_UNSUPP_AS_A_SEARCH_TERM;
else
return rpn2solr_simple(ct, pr, client_data,
q->u.simple->u.attributesPlusTerm, w, 0);
else
return rpn2solr_simple(ct, pr, client_data,
q->u.simple->u.attributesPlusTerm, w, 0);
@@
-385,20
+372,19
@@
static int rpn2solr_structure(solr_transform_t ct,
r = rpn2solr_structure(ct, pr, client_data, q->u.complex->s1, 1, w);
if (r)
return r;
r = rpn2solr_structure(ct, pr, client_data, q->u.complex->s1, 1, w);
if (r)
return r;
- switch(op->which)
+ switch (op->which)
{
{
- case Z_Operator_and:
+ case Z_Operator_and:
pr(" AND ", client_data);
break;
pr(" AND ", client_data);
break;
- case Z_Operator_or:
+ case Z_Operator_or:
pr(" OR ", client_data);
break;
pr(" OR ", client_data);
break;
- case Z_Operator_and_not:
+ case Z_Operator_and_not:
pr(" AND NOT ", client_data);
break;
pr(" AND NOT ", client_data);
break;
- case Z_Operator_prox:
- solr_transform_set_error(ct, YAZ_BIB1_UNSUPP_SEARCH, 0);
- return -1;
+ case Z_Operator_prox:
+ return YAZ_BIB1_UNSUPP_SEARCH;
}
r = rpn2solr_structure(ct, pr, client_data, q->u.complex->s2, 1, w);
if (nested)
}
r = rpn2solr_structure(ct, pr, client_data, q->u.complex->s2, 1, w);
if (nested)
@@
-414,8
+400,9
@@
int solr_transform_rpn2solr_stream(solr_transform_t ct,
{
int r;
WRBUF w = wrbuf_alloc();
{
int r;
WRBUF w = wrbuf_alloc();
- solr_transform_set_error(ct, 0, 0);
r = rpn2solr_structure(ct, pr, client_data, q->RPNStructure, 0, w);
r = rpn2solr_structure(ct, pr, client_data, q->RPNStructure, 0, w);
+ if (r)
+ solr_transform_set_error(ct, r, 0);
wrbuf_destroy(w);
return r;
}
wrbuf_destroy(w);
return r;
}
@@
-425,7
+412,7
@@
int solr_transform_rpn2solr_wrbuf(solr_transform_t ct,
WRBUF w,
Z_RPNQuery *q)
{
WRBUF w,
Z_RPNQuery *q)
{
- return solr_transform_rpn2solr_stream(ct, wrbuf_vputs, w, q);
+ return solr_transform_rpn2solr_stream(ct, wrbuf_vp_puts, w, q);
}
/*
}
/*