The UserOrder command allows to configure a user defined ordering of the documents.
The default way of sorting by a user defined section is possible with help of s=S&su=secname search parameters, however it can be slow in case of a big database. UserOrder allows to improve performance of ordering by a user defined section by preliminary caching the data required for sorting in a quickly accessible format.
The sorting data is cached in the database whenever indexer -Eblob or indexer -Erewritelimits is run.
When processing the s=S&su=secname
search parameters,
search.cgi checks if cached sorting data for
fast ordering presents in the database and uses the cached data on success.
Otherwise, it switches to the slow method of ordering by direct query
to the urlinfo
table.
The first parameter name
stands for the user order name.
The second parameter sql-query
represents an SQL
query which returns a result set consisting of a single column
with values corresponding to ID
s of the documents.
The ID
s must be returned in the desired
order by using the ORDER BY
clause in the SQL query.
The SQL query should typically fetch data
from the table url
(using the column rec_id
) or
the table urlinfo
(using the column url_id
).
Note: The
ID
s of the documents are stored in the rec_id column of the url table of mnoGoSearch database. To know anID
of a certain document you can run this SQL query:SELECT rec_id FROM url WHERE url='http://hostname/page1.html';
It is possible to configure multiple UserOrder commands in the same indexer.conf. The name argument must be unique in every UserOrder command.
search.cgi detects which UserOrder command to use by taking its name from the su=secname search parameter. If no su parameter is given, or the su value is empty, then non of the UserOrder commands are applied for ordering.