-/* $Id: zsets.c,v 1.110 2006-08-14 10:40:15 adam Exp $
+/* $Id: zsets.c,v 1.112 2006-10-29 17:20:01 adam Exp $
Copyright (C) 1995-2006
Index Data ApS
static int log_level_searchterms=0;
static int log_level_resultsets=0;
-static void loglevels()
+static void loglevels(void)
{
if (log_level_set)
return;
struct sortKeyInfo {
int relation;
-#if 0
- int attrUse;
-#else
int ord;
-#endif
int numerical;
+ int index_type;
};
void resultSetInsertSort(ZebraHandle zh, ZebraSet sset,
cmp_buf[j] + i * SORT_IDX_ENTRYSIZE;
if (criteria[j].numerical)
{
- double diff = atof(this_entry_buf) - atof(other_entry_buf);
- rel = 0;
+ char this_entry_org[1024];
+ char other_entry_org[1024];
+ double diff;
+ int index_type = criteria[j].index_type;
+ zebra_term_untrans(zh, index_type, this_entry_org,
+ this_entry_buf);
+ zebra_term_untrans(zh, index_type, other_entry_org,
+ other_entry_buf);
+ diff = atof(this_entry_org) - atof(other_entry_org);
+
if (diff > 0.0)
rel = 1;
else if (diff < 0.0)
rel = -1;
+ else
+ rel = 0;
}
else
{
sort_criteria[i].ord =
zebraExplain_lookup_attr_str(zh->reg->zei,
zinfo_index_category_sort,
- 's',
- sk->u.sortField);
+ -1, sk->u.sortField);
if (sks->which != Z_SortKeySpec_null
&& sort_criteria[i].ord == -1)
{
case Z_SortKey_sortAttributes:
yaz_log(log_level_sort, "key %d is of type sortAttributes", i+1);
res = zebra_sort_get_ord(zh, sk->u.sortAttributes,
+
&sort_criteria[i].ord,
&sort_criteria[i].numerical);
if (sks->which != Z_SortKeySpec_null && res != ZEBRA_OK)
return ZEBRA_FAIL;
break;
}
+ if (zebraExplain_lookup_ord(zh->reg->zei, sort_criteria[i].ord,
+ &sort_criteria[i].index_type,
+ 0, 0))
+ {
+ zebra_setError(zh, YAZ_BIB1_CANNOT_SORT_ACCORDING_TO_SEQUENCE, 0);
+ return ZEBRA_FAIL;
+ }
}
/* allocate space for each cmpare buf + one extra for tmp comparison */
for (i = 0; i<num_criteria; i++)