On Jul 20, 2010, at 4:40, Bill Janssen <jans...@parc.com> wrote:
Looks like the combination of JCC 2.6 and Lucene 2.9.3 have made some
significant API changes. This is what I get with 2.9.3:
% python /u/python/uplib/indexing.py search /local/demo-repo/index
picasso
[...]
hits are <Hits: org.apache.lucene.search.h...@f6f3dc> (0 hits)
Traceback (most recent call last):
File "/u/python/uplib/indexing.py", line 930, in <module>
search(sys.argv[2], sys.argv[3:])
File "/u/python/uplib/indexing.py", line 897, in search
print c.search(' '.join(searchterms))
File "/u/python/uplib/indexing.py", line 687, in search
for hit in hits:
lucene.JavaError: java.lang.IndexOutOfBoundsException: Not a valid
hit number: 0
Java stacktrace:
java.lang.IndexOutOfBoundsException: Not a valid hit number: 0
at org.apache.lucene.search.Hits.hitDoc(Hits.java:215)
at org.apache.lucene.search.Hits.doc(Hits.java:168)
In other words, Hits are now something I can take the length of, but
cannot enumerate? Have we switched to TopDocs already?
There was a bug in jcc that assumed an Iterable out of Hits because of
its iterator() method. But Hits doesn't actually implement Iterable
(it's a Java 1.5 thing and Lucene 2.x is Java 1.4 compatible) it only
mimicks it. You can call hits.iterator() for the same effect. See the
tests and samples that use this class.
Yes, Hits is deprecated and moving to TopDocs is recommended as well.
Andi..
% python /u/python/uplib/indexing.py search /local/demo-repo/index
Apple
[...]
hits are <Hits: org.apache.lucene.search.h...@f4b0dc> (12)
Traceback (most recent call last):
File "/u/python/uplib/indexing.py", line 930, in <module>
search(sys.argv[2], sys.argv[3:])
File "/u/python/uplib/indexing.py", line 897, in search
print c.search(' '.join(searchterms))
File "/u/python/uplib/indexing.py", line 688, in search
doc = Hit.cast_(hit).getDocument()
TypeError: Document<stored/uncompressed,indexed<id:
01182-38-8512-609> stored/uncompressed,indexed<uplibdate:20070620>
stored/uncompressed,indexed<uplibtype:whole> stored/
uncompressed,indexed<categories:_(all)_>>
%
Bill