Why Query, TermQuery etc. are not longer implementing Serializable in Lucene 4.0?

后端 未结 1 408
太阳男子
太阳男子 2021-01-23 12:11

I need to send a class containing Lucene elements such as Query over the network using EJB and of course this class need to be serialized. I marked my class as

相关标签:
1条回答
  • 2021-01-23 13:05

    Mike McCandless, one of Lucene contributors as well as Lucene 4 changelog say:

    All serialization code has been removed from Lucene's classes; you must handle serialization at a higher level in your application.

    The actual commits were done against JIRA issues LUCENE-2908 and LUCENE-4037. The description of the former issue says:

    We removed contrib/remote, but forgot to cleanup serialization hell everywhere. this is no longer needed, never really worked (e.g. across versions), and slows development (e.g. i wasted a long time debugging stupid serialization of Similarity.idfExplain when trying to make a patch for the scoring system).

    Lucene is not alone thinking about throwing away serialization. For example, guava considered this, too.

    Speaking about your problem - you should be able to always convert your query to a String representation (using .toString()) and back. Unless you do this million times a second, the overhead should be negligible.

    0 讨论(0)
提交回复
热议问题