Vítězslav Plšek
2011-May-23 08:55 UTC
[Xapian-discuss] More relevance for recent documents
Good afternoon 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")))); Is there some way how to give more relevance to the recent documents? Would be solution possible in PHP where is still some problem with subclasing Xapian classes? I will be glad for any suggestions Thank you for your time Sincerely Pl?ek V?t?zslav -- S pozdravem V?t?zslav Pl?ek program?tor QCM, s.r.o. Her?pick? 813/5, 639 00 BRNO email: vitezslav.plsek at qcm.cz tel.: +420 538 702 714 web: www.qcm.cz www.vhodne-uverejneni.cz - port?l pro vhodn? uve?ejn?n? www.marwel.cz - publika?n? syst?m a port?lov? ?e?en? www.ezak.cz - ve?ejn? zak?zky elektronicky
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