[Xapian-discuss] Editor's pick
Olly Betts
olly at survex.com
Tue Feb 21 20:30:57 GMT 2006
On Tue, Feb 21, 2006 at 07:40:49AM +0100, Lukasz Keler wrote:
> I have major index. I would like to have some manualy selected documents
> (editor's pick for some keyword) presented in search results before
> other documents and sorted by some additional criteria (rank).
>
> In example:
>
> Main Index: (Doc/Keywords)
> 1. computer, mobile, palmtop, ...
> 2. computer, mobile, ...
> 3. mobile, ...
>
> Editor's pick for keyword mobile: (Doc/Rank)
> 2. 9
> 3. 4
>
> So results for query "mobile" be:
> document 2 (rank 9)
> document 3 (rank 4)
> other documents matching keyword
>
> How to to this?
If you want to present this as an effectively seaparate set of search
results (like Google's adwords, or the magic "stock quote", "news",
"google print", etc links that sometimes appear above the main results),
then just put the editor's picks into a separate database. You can
search the two databases together if you want to offer a search with the
"picks" treated as any other document.
Alternatively, if you want the results in the same list, but to float to
the top, the easiest approach is to set a value on documents which are
editor's picks, containing the "pick rank" (use Document::add_value() at
index time).
Then at search time call Enquire::sort_by_value_the_relevance() on that
value number. The sort is a string sort, so you need to zero (or space)
pad to the width of the widest rank value.
You don't need to set this value on normal documents - documents without
a value set will sort below those with any value set.
Cheers,
Olly
More information about the Xapian-discuss
mailing list