if (n < 500)
seqno[n++] = (*kctrl->getseq)(p->buf[0]);
}
- for (i = 0; i<n; i++)
+ /* set up return buffer.. (save buf[1]) */
+ memcpy(buf, p->buf[1], kctrl->key_size);
+ if (term)
+ *term = p->terms[1];
+ while (1)
{
- zint diff = (*kctrl->getseq)(p->buf[1]) - seqno[i];
- int excl = info->exclusion;
- if (!info->ordered && diff < 0)
- diff = -diff;
- switch (info->relation)
+ for (i = 0; i < n; i++)
{
- case 1: /* < */
- if (diff < info->distance && diff >= 0)
- excl = !excl;
- break;
- case 2: /* <= */
- if (diff <= info->distance && diff >= 0)
- excl = !excl;
- break;
- case 3: /* == */
- if (diff == info->distance && diff >= 0)
- excl = !excl;
- break;
- case 4: /* >= */
- if (diff >= info->distance && diff >= 0)
- excl = !excl;
- break;
- case 5: /* > */
- if (diff > info->distance && diff >= 0)
- excl = !excl;
+ zint diff = (*kctrl->getseq)(p->buf[1]) - seqno[i];
+ int excl = info->exclusion;
+ if (!info->ordered && diff < 0)
+ diff = -diff;
+ switch (info->relation)
+ {
+ case 1: /* < */
+ if (diff < info->distance && diff >= 0)
+ excl = !excl;
+ break;
+ case 2: /* <= */
+ if (diff <= info->distance && diff >= 0)
+ excl = !excl;
+ break;
+ case 3: /* == */
+ if (diff == info->distance && diff >= 0)
+ excl = !excl;
+ break;
+ case 4: /* >= */
+ if (diff >= info->distance && diff >= 0)
+ excl = !excl;
+ break;
+ case 5: /* > */
+ if (diff > info->distance && diff >= 0)
+ excl = !excl;
+ break;
+ case 6: /* != */
+ if (diff != info->distance && diff >= 0)
+ excl = !excl;
+ break;
+ }
+ if (excl)
+ {
+ p->more[1] = rset_read ( p->rfd[1], p->buf[1],
+ &p->terms[1]);
+ p->hits++;
+ return 1;
+ }
+ }
+ p->more[1] = rset_read(p->rfd[1], p->buf[1], &p->terms[1]);
+ if (!p->more[1])
break;
- case 6: /* != */
- if (diff != info->distance && diff >= 0)
- excl = !excl;
+ cmp = (*kctrl->cmp)(buf, p->buf[1]);
+ if (cmp <= - rfd->rset->scope || cmp >= rfd->rset->scope)
break;
- }
- if (excl)
- {
- memcpy (buf, p->buf[1], kctrl->key_size);
- if (term)
- *term = p->terms[1];
- p->more[1] = rset_read ( p->rfd[1], p->buf[1],
- &p->terms[1]);
- p->hits++;
- return 1;
- }
}
- p->more[1] = rset_read (p->rfd[1], p->buf[1], &p->terms[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));
+
+ /* 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 c a", 1));
+ /* exl=0 distance=1 order=1 relation=2 (<=), known, unit=word */
+ YAZ_CHECK(tl_query(zh, "@attr 1=1016 @prox 0 1 1 2 k 2 c a", 1));
+
/* 3 term @prox test.. */
YAZ_CHECK(tl_query(zh, "@attr 1=1016 \"a b c\"", 1));
/* 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 *
+ /* 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) */