FieldDoc is a subclass of ScoreDoc. If the java code expects that the scoreDocs array in the TopFieldDocs instance, which is declared as ScoreDoc[], is actually containing FieldDoc instances and if that fact gets lost during serialization/deserialization, then you get exactly that error when java downcasts the ScoreDoc instance to a FieldDoc.
Basically, I'm saying that you cannot statically expect the scoreDocs array in a TopFieldDocs instance to contain just ScoreDoc instances, it actually tends to contain FieldDoc instances, which is legal since FieldDoc is a subclass of ScoreDoc.
Andi..
On Sat, 5 Feb 2005, Yura Smolsky wrote:
Hello, Yura.
I have found that problem is about initialization of ScoreDoc object. When I use existent ScoreDoc object created by java then everything is okay. When I use ScoreDoc object created in python -> it produces exception.
Check new attach.
YS> Hello, Andi.
YS> I just have added TopFieldDocs manual creation code. This code does YS> recreate TopFieldDocs object using PyLucene classes ScoreDoc, YS> SortField and TopFieldDocs. Check attached file. YS> This example returns exeption:
YS> D:\workshop\blogz-src>d:\work\python24\python.exe RemoteSearch2.py YS> in searchSorted YS> ['"modified"!'] YS> 249 1.0 YS> 269 0.282842695713 YS> 4 0.34999999404 YS> 52 0.17499999702 YS> modified 3 True YS> in searchSorted, finished YS> Exception in thread "MultiSearcher thread #1" YS> java.lang.ClassCastException: org.apache.lucene.search.ScoreDoc YS> cannot be cast to YS> org.apache.lucene.search.FieldDoc YS> *** Got java.lang.NullPointerException while trying to print stack trace. YS> 4
AV>> I verified, by modifying the RemoteSearcher.py code you sent me yesterday that AV>> 'searchSorted' is working properly. The code is attached.
AV>> Andi..
AV>> On Sat, 5 Feb 2005, Yura Smolsky wrote:
Hello, pylucene-dev.
I use ParallelMultiSearcher and I construct manually variables passed to search, searchSorted methods of Searchable implementation. I got this exception when I use sort and ParallerMultiSearcher:
scoreDoc: 261 scoreDoc: 211 ... skipped ... scoreDoc: 142 scoreDoc: 144 Exception in thread "MultiSearcher thread #1" java.lang.ClassCastException: org.apache.lucene.search.ScoreDoc cannot be cast to org.apache.lucene.search.FieldDoc at 0x012ce0ae (Unknown Source) ... skipped hits: 18
if I do not use sort or if I use Searchable implementation through searchSorted then everything is ok. I do not understand this.. Who is messing the data?.. Maybe method searchSorted of implementation of Searchable generates "bad" PyLucene classes?..
Thanks in advance.
Yura SmolskyAV>>
YS> Yura Smolsky, YS>
Yura Smolsky,
_______________________________________________ pylucene-dev mailing list [email protected] http://lists.osafoundation.org/mailman/listinfo/pylucene-dev
