List Info

Thread: Hits.__iter__




Hits.__iter__
user name
2006-04-18 14:10:46
In PyLucene 1.9 (haven't checked the new 2.0 stuff yet),
Hits.__iter__ 
uses a HitsEnumeration object that returns each document in
the hits 
list.  Would it make more sense for __iter__ to be
implemented with the 
Hits.iterator() method (also not exposed in PyLucene 1.9)? 
Doing this 
would be a bit more consistent with what a Java Lucene user
would 
expect, and it lets us get the score for each document as
well as the 
document itself, using the clean Python looping syntax.

currently:

hits = searcher.search(query)
for i in range(hits.length()):
   print hits.doc(i)
   print hits.score(i)

Using a more Java-Lucene-ish way:

hits = searcher.search(query)
for hit in hits:
   print hit.getDocument()
   print hit.getScore()

Anyhow, I'd like it more that way...

_______________________________________________
pylucene-dev mailing list
pylucene-devosafoundation.org
http://lists.osafoundation.org/mailman/listinfo/pylu
cene-dev
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )