Lucene 1.4 (now in release candidate stage) includes built-in sorting capabilities, so I definitely recommend you have a look at that. SearchBean is effectively deprecated based on this new much more powerful feature.

        Erik

On May 18, 2004, at 11:42 AM, Timothy Stone wrote:

Lucene Users,

I'm using the SearchBean contribution from the sandbox to implement a Struts application search with Lucene (taking ACO's advice and going MVC on the demo app.)

Right now I'm having a problem with using any Document objects that might be available and getting an IOException.

So basically what I'm doing, and pardon the marshalling code, etc.

I have an action that determines the users desired search (internal via Lucene or external via Google) and forwards appropiately. If the search is directed to Lucene I create new SearchBean using:

    searchBean = new SearchBean(
                         FSDirectory.getDirectory(
                             getServlet().getInitParameter( "index" ),
                             false ),
                     query );

This bean is put on the request for use in the results.jsp page.

I'm able to quite a bit of work with the bean, determine hits, page counts, etc. except yank a document and display the indexed fields (I'm using the org.apache.lucene.demo.IndexHTML) such as "title", "summary", and "url".

curr position: <%= searchBean.getHitsIterator().getCurrentPosition() %>

<%  if( searchBean.getHitsIterator().hasNext() ) {
        Document doc = searchBean.getHitsIterator().next(); // BOOM!
    }
%>

Any ideas? I only see K. Burton's FSDirectory patch in the archives, but nothing I don't have from CVS.

Here's the stack trace:

java.io.IOException: Bad file descriptor
at java.io.RandomAccessFile.seek(Native Method)
at org.apache.lucene.store.FSInputStream.readInternal(FSDirectory.java: 428)
at org.apache.lucene.store.InputStream.refill(InputStream.java:196)
at org.apache.lucene.store.InputStream.readByte(InputStream.java:81)
at org.apache.lucene.store.InputStream.readInt(InputStream.java:111)
at org.apache.lucene.store.InputStream.readLong(InputStream.java:134)
at org.apache.lucene.index.FieldsReader.doc(FieldsReader.java:96)
at org.apache.lucene.index.SegmentReader.document(SegmentReader.java:275)
at org.apache.lucene.search.IndexSearcher.doc(IndexSearcher.java:107)
at org.apache.lucene.search.Hits.doc(Hits.java:130)
at org.apache.lucene.beans.HitsIterator.getDoc(HitsIterator.java:161)
at org.apache.lucene.beans.HitsIterator.next(HitsIterator.java:139)
at org.apache.jsp.results_jsp._jspService(results_jsp.java:117)


...

Many thanks,
Tim

--
/**
 * Timothy Stone  . www.petmystone.com
 * Harrisburg PA  . javafueled at petmystone.com
 * USA            . coffee fueled macintosh zealot
 *
 * "This Satan's drink [coffee] is so
 *  delicious, we shall cheat Satan and
 *  baptize it."
 *  --Pope Clement VIII
 */

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to