+ last_term = -1;
+ /* find min with lowest sysno */
+ for (i = 0; i<parms->no_isam_positions; i++)
+ {
+ if (isam_r[i] &&
+ (min < 0 || (r = (*parms->cmp)(isam_buf[i], isam_buf[min])) < 2))
+ {
+ min = i;
+ co_oc = 1;
+ }
+ else if (!r && last_term != parms->term_no[i]) /* new occurrence */
+ co_oc++;
+ last_term = parms->term_no[i];
+ }
+
+ if (min < 0)
+ break;
+ memcpy (isam_tmp_buf, isam_buf[min], info->key_size);
+ /* calculate for all with those sysno */
+ for (i = 0; i < parms->no_terms; i++)
+ tf[i] = 0;
+ for (i = 0; i<parms->no_isam_positions; i++)
+ {
+ int r;
+
+ if (isam_r[i])
+ r = (*parms->cmp)(isam_buf[i], isam_tmp_buf);
+ else
+ r = 2;
+ if (r <= 1 && r >= -1)
+ {
+ do
+ {
+ tf[parms->term_no[i]]++;
+ isam_r[i] = is_readkey (isam_pt[i], isam_buf[i]);
+ } while (isam_r[i] &&
+ (*parms->cmp)(isam_buf[i], isam_tmp_buf) <= 1);
+ }
+ }
+ /* calculate relevance value */
+ score = 0.0;
+ for (i = 0; i<parms->no_terms; i++)
+ if (tf[i])
+ score += SCORE_SHOW + SCORE_COOC*co_oc/parms->no_terms +
+ SCORE_DYN*tf[i]/max_tf[i];
+ /* if value is in the top score, then save it - don't emit yet */
+ add_rec (info, score/parms->no_terms, isam_tmp_buf);
+ }
+ for (i = 0; i<info->no_rec; i++)
+ info->sysno_idx[i] = i;
+ qsort_info = info;
+ qsort (info->sysno_idx, info->no_rec, sizeof(*info->sysno_idx), qcomp);