lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Allahbaksh Mohammedali Asadullah <>
Subject Boost value corrupted "read eof exception"
Date Fri, 15 Feb 2008 16:53:29 GMT

I am using lucene 2.3. The exception is properly handled when I run the program by lucene
but when I debug it it hit the exception at addDocuement.





import org.apache.lucene.document.Field;


import org.apache.lucene.index.IndexWriter;

import org.apache.lucene.document.Document;




import org.apache.lucene.queryParser.QueryParser;

import org.apache.lucene.queryParser.ParseException;

import org.apache.lucene.analysis.StopAnalyzer;

import org.apache.lucene.analysis.standard.StandardAnalyzer;

public class InMemoryExample {

    public static void main(String[] args) throws IOException {

        // Construct a RAMDirectory to hold the in-memory representation

        // of the index.

        RAMDirectory idx = new RAMDirectory();

        FSDirectory fs =FSDirectory.getDirectory("Z:\\lucene_index");


        try {

            // Make an writer to create the index

            IndexWriter writer =

                new IndexWriter(fs,  true,new StandardAnalyzer());

            // Add some Document objects containing quotes

            writer.addDocument(createDocument("Theodore Roosevelt",

            //    "It behooves every man to remember that the work of the " +

              //  "critic, is of altogether secondary importance, and that, " +

              //"in the end, progress is accomplished by the man who does " +


            writer.addDocument(createDocument("Friedrich Hayek",

//                "The case for individual freedom rests largely on the " +

                        //"recognition of the inevitable and universal ignorance " +

                //"of all of us concerning a great many of the factors on " +

                "which the achievements of our ends and welfare depend."),new StandardAnalyzer());

            writer.addDocument(createDocument("Ayn Rand",

                //"There is nothing to take a man's freedom away from " +

                //"him, save other men. To be free, a man must be free " +

                "of his brothers."));

            writer.addDocument(createDocument("Mohandas Gandhi",

                //"Freedom is not worth having if it does not connote " +

                "freedom to err."));

            // Optimize and close the writer to finish building the index

           // writer.optimize();


            // Build an IndexSearcher using the in-memory index

            Searcher searcher = new IndexSearcher(fs);

            // Run some queries

            search(searcher, "freedom");

            search(searcher, "free");

            search(searcher, "progress or achievements");



        catch(IOException ioe) {

            // In this example we aren't really doing an I/O, so this

            // exception should never actually be thrown.



        catch(ParseException pe) {



    }    private static Document createDocument(String title, String content) {

        Document doc = new Document();

        // Add the title as an unindexed field...

        Field f1 = new Field("title",title, Field.Store.YES,Field.Index.TOKENIZED);

        float temp = (float)Math.random();

        System.out.print("Title of document is "+title +" Field 1 Boost value "+temp);



        // ...and the content as an indexed field. Note that indexed

        // Text fields are constructed using a Reader. Lucene can read

        // and index very large chunks of text, without storing the

        // entire content verbatim in the index. In this example we

        // can just wrap the content string in a StringReader.

        temp =(float)Math.random();

        Field f2 =new Field("content",content,Field.Store.YES,Field.Index.TOKENIZED);



        System.out.println(" Field 2 Boost value is " +temp);

        return doc;



Allahbaksh Mohammedali Asadullah,
Software Engineering & Technology Labs,
Infosys Technolgies Limited, Electronics City,
Hosur Road, Bangalore 560 100, India.
*Board: +91-80-28520261 | Extn: 53915 | Direct: 41173915.
Fax: +91-80-28520362 | Mobile: +91-9845505322.

-----Original Message-----
From: Michael McCandless []
Sent: Friday, February 15, 2008 9:57 PM
Subject: Re: Boost value corrupted "read eof exception"

Which version of Lucene are you using?

Can you post the full stack trace for the exception you're hitting?


Allahbaksh Mohammedali Asadullah wrote:

> Hi,
> I am getting read past eof  exception when I am adding Document.
> The things works fine but while I read the Boost value I get it as
> default value i.e 1.0. I tried using RAMDirectory then also I am
> getting the same error.
> Can someone throw some light on this.
> Warm Regards,
> Allahbaksh
> **************** CAUTION - Disclaimer *****************
> intended solely for the use of the addressee(s). If you are not the
> intended recipient, please notify the sender by e-mail and delete
> the original message. Further, you are not to copy, disclose, or
> distribute this e-mail or its contents to any other person and any
> such actions are unlawful. This e-mail may contain viruses. Infosys
> has taken every reasonable precaution to minimize this risk, but is
> not liable for any damage you may sustain as a result of any virus
> in this e-mail. You should carry out your own virus checks before
> opening the e-mail or attachment. Infosys reserves the right to
> monitor and review the content of all messages sent to or from this
> e-mail address. Messages sent to or from this e-mail address may be
> stored on the Infosys e-mail system.
> ***INFOSYS******** End of Disclaimer ********INFOSYS***

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message