[Zope-CVS] CVS: Products/ZCTextIndex - ZCTextIndex.py:1.12

Jeremy Hylton jeremy@zope.com
Thu, 16 May 2002 11:31:59 -0400


Update of /cvs-repository/Products/ZCTextIndex
In directory cvs.zope.org:/tmp/cvs-serv9252

Modified Files:
	ZCTextIndex.py 
Log Message:
Move query() and numObjects() above comment about pluggable index API.


=== Products/ZCTextIndex/ZCTextIndex.py 1.11 => 1.12 ===
         self.clear()
 
+    def query(self, query, nbest=10):
+        """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(), len(results)
+
+    def numObjects(self):
+        """Return number of object indexed"""
+        return self.index.length()
+
     ## Pluggable Index APIs ##
 
     def index_object(self, docid, obj, threshold=None):
@@ -92,22 +108,6 @@
         tree = QueryParser().parseQuery(query_str)
         results = tree.executeQuery(self.index)
         return  results, (self._fieldname,)
-
-    def query(self, query, nbest=10):
-        """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(), len(results)
-
-    def numObjects(self):
-        """Return number of object indexed"""
-        return self.index.length()
 
     def getEntryForObject(self, documentId, default=None):
         """Return the list of words indexed for documentId"""