From: Adam Dickmeiss Date: Mon, 24 Aug 2009 12:28:54 +0000 (+0200) Subject: Left-assoc for proximity code and tests for it X-Git-Tag: v2.0.41~1 X-Git-Url: http://git.indexdata.com/?p=idzebra-moved-to-github.git;a=commitdiff_plain;h=8664d6939b6be2e0de78c81ff99b8e24d304abc3;hp=6f37c3dd623bae17b02aecdec4357529a0d4627d Left-assoc for proximity code and tests for it --- diff --git a/rset/rsprox.c b/rset/rsprox.c index 896854e..6972828 100644 --- a/rset/rsprox.c +++ b/rset/rsprox.c @@ -194,10 +194,11 @@ static int r_forward(RSFD rfd, void *buf, TERMID *term, const void *untilbuf) } if (i == ct->no_children) { - memcpy (buf, p->buf[0], kctrl->key_size); + i = ct->no_children-1; + memcpy(buf, p->buf[i], kctrl->key_size); if (term) - *term = p->terms[0]; - p->more[0] = rset_read (p->rfd[0], p->buf[0], &p->terms[0]); + *term = p->terms[i]; + p->more[i] = rset_read(p->rfd[i], p->buf[i], &p->terms[i]); p->hits++; return 1; } diff --git a/test/api/test_search.c b/test/api/test_search.c index b42d5ee..80e75d3 100644 --- a/test/api/test_search.c +++ b/test/api/test_search.c @@ -243,6 +243,24 @@ static void tst(int argc, char **argv) /* exl=0 distance=2 order=1 relation=2 (<=), known, unit=word */ YAZ_CHECK(tl_query(zh, "@attr 1=1016 @prox 0 2 1 2 k 2 a y", 1)); + /* exl=0 distance=1 order=1 relation=3 (=), known, unit=word */ + YAZ_CHECK(tl_query(zh, "@attr 1=1016 @prox 0 1 1 3 k 2 a b", 1)); + + /* 3 term @prox test.. */ + YAZ_CHECK(tl_query(zh, "@attr 1=1016 \"a b c\"", 1)); + + /* exl=0 distance=1 order=1 relation=2 (<=), known, unit=word */ + /* right associative (does not work, so zero hits) */ + YAZ_CHECK(tl_query(zh, "@attr 1=1016 @prox 0 1 1 2 k 2 a @prox 0 1 1 2 k 2 b c", 0)); + /* left associative (works fine) */ + YAZ_CHECK(tl_query(zh, "@attr 1=1016 @prox 0 1 1 2 k 2 @prox 0 1 1 2 k 2 a b c", 1)); + + /* exl=0 distance=1 order=1 relation=3 (=), known, unit=word * + /* right associative (does not work, so zero hits) */ + YAZ_CHECK(tl_query(zh, "@attr 1=1016 @prox 0 1 1 3 k 2 a @prox 0 1 1 3 k 2 b c", 0)); + /* left associative (works fine) */ + YAZ_CHECK(tl_query(zh, "@attr 1=1016 @prox 0 1 1 3 k 2 @prox 0 1 1 3 k 2 a b c", 1)); + /* Non-indexed numeric use, but specified in bib1.att (bug #1142) */ YAZ_CHECK(tl_query_x(zh, "@attr 1=1000 x", 0, 114)); YAZ_CHECK(tl_query_x(zh, "@attr 1=1000 @attr 14=0 x", 0, 114));