On Wed, 10 May 2006, Steven Bethard wrote:

I couldn't figure out the rationale for having Hits and IndexReader
objects generate index/document tuples when iterated instead of simply
generating the documents.  This makes the distinctly unlike Python
lists, where to get such behavior you'd use enumerate like::

  for i, doc in enumerate(hits):
      ...

I assume this was discussed somewhere, but I couldn't find the
discussion.  Could someone point me there?

The reason is that when iterating hits you might need the hit number to access more information from the hits such as the score of the hit. In other words, a enumeration of hits is more than an enumeration of docs.

In PyLucene 2.0, I've changed it so that it works more like the new Java Lucene HitIterator class and returns a Hit object from which the doc, score, etc... can be accessed. In order to remain backwards compatible with the earlier form, the Hit object expands into (i, doc) when asked to do so (it implements a sequence of two elements).

PyLucene 2.0 is available from PyLucene's svn repository trunk. Its actual release is waiting for Java Lucene 2.0 to be released which hasn't happened yet.

Andi..
_______________________________________________
pylucene-dev mailing list
[email protected]
http://lists.osafoundation.org/mailman/listinfo/pylucene-dev

Reply via email to