- struct ord_list *ol = terms[i]->ol;
-
- yaz_log(log_level, "begin() term i=%d flags=%s '%s'", i,
- terms[i]->flags, terms[i]->name );
-
- for (; ol; ol = ol->next)
- {
- int index_type = 0;
- const char *db = 0;
- const char *string_index = 0;
- int set = -1;
- int use = -1;
-
- zebraExplain_lookup_ord(reg->zei,
- ol->ord, &index_type, &db, &set, &use,
- &string_index);
-
- if (string_index)
- yaz_log(log_level, "begin() ord=%d index_type=%c db=%s str-index=%s",
- ol->ord, index_type, db, string_index);
- else
- yaz_log(log_level, "begin() ord=%d index_type=%c db=%s set=%d use=%d",
- ol->ord, index_type, db, set, use);
- }
- if (!strncmp (terms[i]->flags, "rank,", 5))
- (si->no_rank_entries)++;
-
- /* setting next entry in term */
- terms[i]->rankpriv = &(si->entries[i]);
+ struct ord_list *ol = NULL;
+
+
+ /* adding to number of rank entries */
+ if (strncmp (terms[i]->flags, "rank,", 5))
+ {
+ si->entries[i].rank_flag = 0;
+ yaz_log(log_level, "begin() terms[%d]: '%s' flags=%s not ranked",
+ i, terms[i]->name, terms[i]->flags);
+ }
+ else
+ {
+ const char *cp = strstr(terms[i]->flags+4, ",w=");
+
+ zint no_docs_fieldindex = 0;
+ zint no_terms_fieldindex = 0;
+
+ yaz_log(log_level, "begin() terms[%d]: '%s' flags=%s",
+ i, terms[i]->name, terms[i]->flags);
+
+ (si->no_ranked_terms_query)++;
+ ol = terms[i]->ol;
+
+ si->entries[i].rank_flag = 1;
+ /* notice that the call to rset_count(rset) has he side-effect
+ of setting rset->hits_limit = rset_count(rset) ??? */
+ si->entries[i].freq_term_resset = rset_count(terms[i]->rset);
+ si->entries[i].no_docs_resset = terms[i]->rset->hits_count;
+
+
+ if (cp)
+ si->entries[i].fieldindex_weight = atoi (cp+3);
+ else
+ si->entries[i].fieldindex_weight = 34; /* sqrroot of 1000 */
+
+
+ /*
+ yaz_log(log_level, "begin() rset_count(terms[%d]->rset) = "
+ ZINT_FORMAT, i, rset_count(terms[i]->rset));
+ yaz_log(log_level, "begin() terms[%d]->rset->hits_limit = "
+ ZINT_FORMAT, i, terms[i]->rset->hits_limit);
+ yaz_log(log_level, "begin() terms[%d]->rset->hits_count = "
+ ZINT_FORMAT, i, terms[i]->rset->hits_count);
+ yaz_log(log_level, "begin() terms[%d]->rset->hits_round = "
+ ZINT_FORMAT, i, terms[i]->rset->hits_round);
+ yaz_log(log_level, "begin() terms[%d]->rset->hits_approx = %d",
+ i, terms[i]->rset->hits_approx);
+ */
+
+ /* looping indexes where term terms[i] is found */
+
+ for (; ol; ol = ol->next)
+ {
+ const char *index_type = 0;
+ const char *db = 0;
+ const char *string_index = 0;
+
+ zebraExplain_lookup_ord(reg->zei,
+ ol->ord, &index_type, &db,
+ &string_index);
+
+ no_docs_fieldindex
+ += zebraExplain_ord_get_doc_occurrences(reg->zei, ol->ord);
+ no_terms_fieldindex
+ += zebraExplain_ord_get_term_occurrences(reg->zei, ol->ord);
+
+ if (string_index)
+ yaz_log(log_level,
+ "begin() index: ord=%d type=%s db=%s str-index=%s",
+ ol->ord, index_type, db, string_index);
+ else
+ yaz_log(log_level,
+ "begin() index: ord=%d type=%s db=%s",
+ ol->ord, index_type, db);
+ }
+
+ si->entries[i].no_docs_fieldindex = no_docs_fieldindex;
+ si->entries[i].no_terms_fieldindex = no_terms_fieldindex;
+ }
+
+ si->entries[i].term = terms[i];
+ si->entries[i].term_index=i;
+
+ /* setting next entry in term */
+ terms[i]->rankpriv = &(si->entries[i]);