increasing or decreasing order according to that field. 0==Decreasing is
the default.
Sort field names can be any field name designated as a sort field
- in the pazpar2.cfg file, or the special name 'relevance'.
+ in the pazpar2.cfg file, or the special names 'relevance' and
+ 'position'.
</para>
</listitem>
</varlistentry>
Metadata_sortkey_relevance,
Metadata_sortkey_numeric, // Standard numerical sorting
Metadata_sortkey_skiparticle, // Skip leading article when sorting
- Metadata_sortkey_string // Flat string
+ Metadata_sortkey_string, // Flat string
+ Metadata_sortkey_position // Position
};
// This controls the ability to insert 'static' values from settings into retrieval recs
if (!strcmp(parm, "relevance"))
{
type = Metadata_sortkey_relevance;
+ }
+ else if (!strcmp(parm, "position"))
+ {
+ type = Metadata_sortkey_position;
}
else
{
else
res = 0;
break;
+ case Metadata_sortkey_position:
+ if (r1->records && r2->records)
+ {
+ int pos1 = 0, pos2 = 0;
+ struct record *rec;
+ for (rec = r1->records; rec; rec = rec->next)
+ if (pos1 == 0 || rec->position < pos1)
+ pos1 = rec->position;
+ for (rec = r2->records; rec; rec = rec->next)
+ if (pos2 == 0 || rec->position < pos2)
+ pos2 = rec->position;
+ if (s->increasing)
+ res = pos1 - pos2;
+ else
+ res = pos2 - pos1;
+ }
+ break;
default:
yaz_log(YLOG_WARN, "Bad sort type: %d", s->type);
res = 0;