[Xapian-discuss] More relevance for recent documents

Olly Betts olly at survex.com
Mon May 23 12:23:46 BST 2011


On Mon, May 23, 2011 at 10:55:24AM +0200, Vít??zslav Pl??ek wrote:
> I would like to ask if is possible somehow give more relevance to the
> recent documents in search results.
> I dont want to sort results according to the date, I still prefer
> relevance, but I would like to see recent documents with better scoring.
> 
> I was trying to add search query using AND_MAYBE, which should use
> relevance from both subqueries, but it didnt add any benefit to the
> resalts which are match by this subquery
> 
>  $query = new XapianQuery(XapianQuery::OP_AND_MAYBE, $query, new
> XapianQuery(XapianQuery::OP_VALUE_GE,  self::DATE, date('Ymd000000',
> strtotime("- 1 year"))));

OP_VALUE_GE returns a weight of zero, so sadly that's not going to
work.  I don't see an easy way around that either.

If you indexed a term for the week or month the document was in,
you could do something similar but use an OR of the recent week/month
terms instead of the value range.

> Is there some way how to give more relevance to the recent documents?

If you use a PostingSource, you can do a more sophisticated version
of what you're strying above and give a variable extra weight so the
more recent the document, the more the boost:

http://xapian.org/docs/postingsource

> Would be solution possible in PHP where is still some problem with
> subclasing Xapian classes?

Unfortunately not, since you'd need to subclass PostingSource.

Cheers,
    Olly



More information about the Xapian-discuss mailing list