From: Adam Dickmeiss Date: Fri, 3 Jan 2014 10:08:16 +0000 (+0100) Subject: rpn2solr: support truncation left(2), left&right(3) YAZ-718 X-Git-Tag: v5.0.10~2 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=406ec3b354a9260bf09cc80c540d3d19845dc915;p=yaz-moved-to-github.git rpn2solr: support truncation left(2), left&right(3) YAZ-718 --- diff --git a/src/rpn2solr.c b/src/rpn2solr.c index 5894abe..c9143c7 100644 --- a/src/rpn2solr.c +++ b/src/rpn2solr.c @@ -243,6 +243,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, "\""); + if (trunc == 2 || trunc == 3) + wrbuf_puts(w, "*"); for (i = 0 ; i < lterm; i++) { if (sterm[i] == '\\' && i < lterm - 1) @@ -268,7 +270,7 @@ static int emit_term(solr_transform_t ct, WRBUF w, Z_Term *term, Odr_int trunc) else wrbuf_putc(w, sterm[i]); } - if (trunc == 1) + if (trunc == 1 || trunc == 3) wrbuf_puts(w, "*"); if (must_quote) wrbuf_puts(w, "\""); @@ -307,7 +309,7 @@ static int rpn2solr_simple(solr_transform_t ct, 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 { diff --git a/test/test_rpn2solr.c b/test/test_rpn2solr.c index 196dfdb..72be5d7 100644 --- a/test/test_rpn2solr.c +++ b/test/test_rpn2solr.c @@ -78,8 +78,8 @@ static void tst1(void) /* Truncation */ YAZ_CHECK(compare(ct, "@attr 5=1 water", "water*")); - YAZ_CHECK(compare(ct, "@attr 5=2 water", 0)); - YAZ_CHECK(compare(ct, "@attr 5=3 water", 0)); + YAZ_CHECK(compare(ct, "@attr 5=2 water", "*water")); + YAZ_CHECK(compare(ct, "@attr 5=3 water", "*water*")); YAZ_CHECK(compare(ct, "@attr 5=100 water", "water")); YAZ_CHECK(compare(ct, "@attr 5=101 water", 0)); YAZ_CHECK(compare(ct, "@attr 5=104 w#ter", "w?ter"));