X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fzsets.c;h=d543abdbfda042bae6a14940352bc0dc5c99b1a3;hb=605079d4ba2e4e687aeace5ea655ca4223566faa;hp=73e45b0b145baf71a0e45bcb1caaaeee321beb98;hpb=58e3c5132f9fe86fefbf2e130275ab9980eeed1e;p=idzebra-moved-to-github.git diff --git a/index/zsets.c b/index/zsets.c index 73e45b0..d543abd 100644 --- a/index/zsets.c +++ b/index/zsets.c @@ -1,5 +1,5 @@ -/* $Id: zsets.c,v 1.46 2003-06-18 11:46:34 adam Exp $ - Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 +/* $Id: zsets.c,v 1.49 2004-06-13 18:45:25 adam Exp $ + Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps This file is part of the Zebra server. @@ -207,6 +207,8 @@ ZebraSet resultSetAdd (ZebraHandle zh, const char *name, int ov) } else { + const char *sort_max_str = zebra_get_resource(zh, "sortmax", "1000"); + yaz_log (LOG_DEBUG, "adding result set %s", name); s = (ZebraSet) xmalloc (sizeof(*s)); s->next = zh->sets; @@ -216,7 +218,10 @@ ZebraSet resultSetAdd (ZebraHandle zh, const char *name, int ov) s->sort_info = (struct zset_sort_info *) xmalloc (sizeof(*s->sort_info)); - s->sort_info->max_entries = 1000; + s->sort_info->max_entries = atoi(sort_max_str); + if (s->sort_info->max_entries < 2) + s->sort_info->max_entries = 2; + s->sort_info->entries = (struct zset_sort_entry **) xmalloc (sizeof(*s->sort_info->entries) * s->sort_info->max_entries); @@ -617,9 +622,9 @@ void resultSetSortSingle (ZebraHandle zh, NMEM nmem, Z_SortKeySpec *sks = sort_sequence->specs[i]; Z_SortKey *sk; - if (*sks->sortRelation == Z_SortRelation_ascending) + if (*sks->sortRelation == Z_SortKeySpec_ascending) sort_criteria[i].relation = 'A'; - else if (*sks->sortRelation == Z_SortRelation_descending) + else if (*sks->sortRelation == Z_SortKeySpec_descending) sort_criteria[i].relation = 'D'; else { @@ -687,7 +692,7 @@ void resultSetSortSingle (ZebraHandle zh, NMEM nmem, rset->rset_terms[i]->flags, rset->rset_terms[i]->count); - *sort_status = Z_SortStatus_success; + *sort_status = Z_SortResponse_success; yaz_log (LOG_LOG, "resultSetSortSingle end"); } @@ -709,6 +714,7 @@ void resultSetRank (ZebraHandle zh, ZebraSet zebraSet, RSET rset) ZebraRankClass rank_class; struct rank_control *rc; struct zset_sort_info *sort_info; + const char *rank_handler_name = res_get_def(zh->res, "rank", "rank-1"); sort_info = zebraSet->sort_info; sort_info->num_entries = 0; @@ -717,7 +723,12 @@ void resultSetRank (ZebraHandle zh, ZebraSet zebraSet, RSET rset) yaz_log (LOG_LOG, "resultSetRank"); - rank_class = zebraRankLookup (zh, res_get_def(zh->res, "rank", "rank-1")); + rank_class = zebraRankLookup (zh, rank_handler_name); + if (!rank_class) + { + yaz_log (LOG_WARN, "No such rank handler: %s", rank_handler_name); + return; + } rc = rank_class->control; if (rset_read (rset, rfd, &key, &term_index))