The UserScore command allows to
configure user defined scores
for some or all documents in the database. The score value
calculated by mnoGoSearch
is mixed with the user defined value,
so you can affect the final rank for desired documents.
It is possible to configure multiple UserScore commands,
however only one of them can be used during search time.
The name argument should be unique
in every UserScore command.
search.cgi detects which
UserScore command to use taking
its name from the us=name1
HTML form parameter. If no us
parameter is given, or us value is empty,
non of the UserScore commands are applied.
The second argument must represent an SQL query returning
a result set consisting of two columns. The first column in each
record should correspond to
ID of a document
whose score should be modified.
IDs are stored in the
rec_id column of the
url table of the mnoGoSearch database.
To know the
ID of a certain document
you can run this SQL query in the mnoGoSearch database:
SELECT rec_id FROM url WHERE url='http://hostname/page1.html';
The second column stands for a user defined score value for this document,
returned as signed integer in the range -255..+255.
The original score
value calculated by mnoGoSearch is mixed with the user defined value as follows:
A positive user defined value makes the final rank for this document higher.
A negative user defined value makes the final rank lower.
A zero user defined value does not change score.
If a document is not represented in a
UserScore SQL query result,
its score is not changed.
If the UserScore command is specified in search.htm,
then the SQL query is executed during search time. This mode can be recommended
for a simple UserScore SQL query with a small number of records
When you have a complex UserScore SQL query
(which needs time for its execution and/or returns a large result set),
then is it's possible
to specify the UserScore command in indexer.conf instead.
In this case the SQL query is evaluated only during
indexer -Eblob or
indexer -Erewritelimits time,
and its result is cached in the database.
At search time search.cgi loads the cached result from the database.
# Give more score to documents with longer URL
UserScore long "SELECT rec_id, length(url) FROM url"
# Give more score to documents with shorter URL
UserScore short "SELECT rec_id, -length(url) FROM url"
# Give higher scores to some certain documents:
UserScore list1 "SELECT rec_id, 255 FROM url WHERE rec_id IN (1,100,300)"