On Mon, 26 Nov 2007, Bill Janssen wrote:

I seem to have a lot of this in my JCC PyLucene code:

   # don't use iteration because it doesn't downcast properly
   # for hit in hits:
   for i in range(len(hits)):
       doc = hits.doc(i)

Instead of

   for hit in hits:
       doc = hit.getDocument()

which I'd prefer.  Am I doing something wrong?

Yes and no.

    for hit in hits:
        doc = Hit.cast_(hit).getDocument()

would do the trick.

Once Java Lucene switches to Java 1.5 and declares that a HitIterator returns Hit objects instead of Object objects, jcc can be changed to take advantage of that new information to apply the correct wrapper.

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

Reply via email to