X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Frpn2solr.c;h=11abe87ade8848da3934f58d09371d29f9679f3f;hb=f1354830c806b65e6ec6dfdc66dba451715608fc;hp=de485ab13a19733f50f25518a7725effabdc1c4a;hpb=24a717fb09063be70ff56dc82e9f03e7673254e0;p=yaz-moved-to-github.git diff --git a/src/rpn2solr.c b/src/rpn2solr.c index de485ab..11abe87 100644 --- a/src/rpn2solr.c +++ b/src/rpn2solr.c @@ -1,13 +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 * \brief Implements RPN to SOLR conversion - * */ +#if HAVE_CONFIG_H +#include +#endif #include #include @@ -183,7 +184,10 @@ static int checkForTruncation(int flag, Z_AttributeList *attributes) if (truncation <= 3) return ((int) truncation & flag); } - /* Complex: Shouldn't happen */ + else if (ae->which == Z_AttributeValue_complex) { + //yaz_log(YLOG_DEBUG, "Z_Attribute_complex"); + /* Complex: Shouldn't happen */ + } } } /* No truncation or unsupported */ @@ -191,11 +195,11 @@ static int checkForTruncation(int flag, Z_AttributeList *attributes) }; static int checkForLeftTruncation(Z_AttributeList *attributes) { - return checkForTruncation(1, attributes); + return checkForTruncation(2, attributes); } static int checkForRightTruncation(Z_AttributeList *attributes) { - return checkForTruncation(2, attributes); + return checkForTruncation(1, attributes); }; static int rpn2solr_simple(solr_transform_t ct, @@ -241,6 +245,7 @@ static int rpn2solr_simple(solr_transform_t ct, { size_t i; int must_quote = 0; + for (i = 0 ; i < lterm; i++) if (sterm[i] == ' ') must_quote = 1; @@ -249,7 +254,13 @@ static int rpn2solr_simple(solr_transform_t ct, /* Bug 2878: Check and add Truncation */ if (checkForLeftTruncation(apt->attributes)) wrbuf_puts(w, "*"); - wrbuf_write(w, sterm, lterm); + /* BUG 4415: Escape : (as \:) in string terms */ + for (i = 0 ; i < lterm; i++) { + if (sterm[i] == ':') { + wrbuf_putc(w, '\\'); + } + wrbuf_putc(w, sterm[i]); + } /* Bug 2878: Check and add Truncation */ if (checkForRightTruncation(apt->attributes)) wrbuf_puts(w, "*");