[Zope-CVS] CVS: Products/ZCTextIndex - ZCTextIndex.py:1.10
Jeremy Hylton
jeremy@zope.com
Wed, 15 May 2002 19:47:31 -0400
Update of /cvs-repository/Products/ZCTextIndex
In directory cvs.zope.org:/tmp/cvs-serv11366
Modified Files:
ZCTextIndex.py
Log Message:
Change query() method of ZCTextIndex to return nbest, num.
Otherwise, there's no way to report the total number of matches from
which the nbest were selected.
I changed all the functional tests that I knew how to fix, but not the
mhindex stuff. All unit tests pass.
=== Products/ZCTextIndex/ZCTextIndex.py 1.9 => 1.10 ===
def query(self, query, nbest=10):
- # returns a mapping from docids to scores
+ """Return pair (mapping from docids to scores, num results).
+
+ The num results is the total number of results before trimming
+ to the nbest results.
+ """
tree = QueryParser().parseQuery(query)
results = tree.executeQuery(self.index)
chooser = NBest(nbest)
chooser.addmany(results.items())
- return chooser.getbest()
-
+ return chooser.getbest(), len(results)
+
def numObjects(self):
"""Return number of object indexed"""
return self.index.length()