[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lucene-user
Subject:    Re: HitCollector not serializable (Bug?)
From:       Manfred Hardt <lucene () fantasymail ! de>
Date:       2003-06-16 20:28:43
[Download RAW message or body]

There should be a comment about this "best practice" in the API/Javadocs.

Manfred

> The HitCollector-based search API is not meant to work remotely.  To do
> so would involve an RPC-callback for every non-zero score, which would
> be extremely expensive.  Also, just making HitCollector serializable
> would not be sufficient.  You'd also need to pass in a HitCollector
> implementation that subclasses UnicastRemoteObject, so that the
> callbacks can return to the original VM.
>
> So, if you can, it's considerably simpler and more efficient to use
> TopDocs-based search when you're working remotely.
>
> Doug
>
> lucene@fantasymail.de wrote:
> > Hi,
> >
> > i tried Lucene 1.3 RC1.
> >
> > There seems to be a bug in
> > org.apache.lucene.search.RemoteSearchable.search().
> >
> > Here is my code:
> >    Searchable searcher =
> >       (Searchable) Naming.lookup(args[0]);
> >    Analyzer analyzer = new StandardAnalyzer();
> >    Query query = QueryParser.parse("term", "content", analyzer);
> >    HitCollector hc = new HitCollector()
> >    {
> >       public void collect(int doc, float score)
> >       {
> >            //bits.set(doc);
> >       }
> >    };
> >
> >    searcher.search(query, (DateFilter)null, hc);
> >
> > I'm getting the following exception:
> >
> > java.rmi.MarshalException: error marshalling arguments; nested exception
> >  is: java.io.NotSerializableException:
> >  com.entwickler.lucenebuch.remote.SearchClient$1
> >          at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:129)
> >          at org.apache.lucene.search.RemoteSearchable_Stub.search(Unknown
> >  Source)
> >          at
> >  com.entwickler.lucenebuch.remote.SearchClient.main(SearchClient.java:47)
> >  Caused by: java.io.NotSerializableException:
> >  com.entwickler.lucenebuch.remote.SearchClient$1
> >          at
> >  java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1054)
> >          at
> >  java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278) at
> >  sun.rmi.server.UnicastRef.marshalValue(UnicastRef.java:265) at
> >  sun.rmi.server.UnicastRef.invoke(UnicastRef.java:124)
> >
> >
> > This happens because org.apache.lucene.search.HitCollector is not
> > serializable.
> >
> >
> > Greetings
> > Manfred
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic