[Xapian-discuss] Ordering search results and defining a custom Weight class in python

Olly Betts olly at survex.com
Sat May 31 02:21:54 BST 2008


On Fri, May 30, 2008 at 05:03:09PM -0700, Robert Kaye wrote:
> 1. Do you have any tips for how to tweak the ordering of our search  
> results? It appears that the desirable results are found, but what we  
> consider to be the best match usually doesn't show up as a 100% rank.  
> Is there any way to tweak this ranking without creating a custom  
> Weight class?

Yes, BM25Weight has several parameters which can be adjusted to change
the emphasis of the weighting.  If your documents are typically quite
short, then you probably will get better results if you make the
document length less important.

> 2. If a custom Weight class is the way to go (which I suspect), does  
> anyone have an example of how to do this in Python? I've tried to port  
> the default C++ example from the docs as such:
> 
> class TinkerWeight(xapian.Weight):
> 
> #   def __init__(self):
> #       xapian.Weight.__init__(self)

xapian.Weight is an abstract base class, so has no constructor, but your
class needs a constructor so it can be constructed.  So I think you
need to write:

    def __init__(self):
        pass

Cheers,
    Olly



More information about the Xapian-discuss mailing list