The 'position' sorts merged records by their original position
from the remote target. This is primarily useful for debugging and
may be used for targets that already perform some kind of relevance
ranking. Note that sort by default is decreasing; so to get records
in their original order sort=position:1 must be used.
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
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>
</para>
</listitem>
</varlistentry>
Metadata_sortkey_relevance,
Metadata_sortkey_numeric, // Standard numerical sorting
Metadata_sortkey_skiparticle, // Skip leading article when sorting
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
};
// This controls the ability to insert 'static' values from settings into retrieval recs
if (!strcmp(parm, "relevance"))
{
type = Metadata_sortkey_relevance;
if (!strcmp(parm, "relevance"))
{
type = Metadata_sortkey_relevance;
+ }
+ else if (!strcmp(parm, "position"))
+ {
+ type = Metadata_sortkey_position;
+ 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;
default:
yaz_log(YLOG_WARN, "Bad sort type: %d", s->type);
res = 0;