Hi Roshan,
                        U've got to get the contents as
                doc(i).get("body")
        The field name has to match what is queried back .

Suneetha.

 NAVENDRA wrote:

> It is being added as a Text field.... which is stored i gather. Is is also being 
>added as as a Reader.... this might be the problem I am not sure.
>
> Here is my code, can anybody please help me.
>
> import org.apache.lucene.analysis.SimpleAnalyzer;
> import org.apache.lucene.index.IndexWriter;
> import org.apache.lucene.document.Document;
> import org.apache.lucene.document.*;
>
> import java.io.*;
>
> public class IndexFiles {
>   // usage: IndexFiles index-path file . . .
>   public static void main(String[] args) throws Exception {
>     String indexPath = args[0];
>     IndexWriter writer;
>
>     writer = new IndexWriter(indexPath, new SimpleAnalyzer(), false);
>     for (int i=1; i<args.length; i++) {
>       System.out.println("Indexing file " + args[i]);
>       InputStream is = new FileInputStream(args[i]);
>
>
>
>       // We create a Document with two Fields, one which contains
>       // the file path, and one the file's contents.
>       Document doc = new Document();
>       doc.add(Field.UnIndexed("path", args[i]));
>       doc.add(Field.Text("body", (Reader) new InputStreamReader(is)));
>
>       writer.addDocument(doc);
>       is.close();
>     };
>
>     writer.close();
>   }
> }
>
> >>> [EMAIL PROTECTED] 03/14/02 03:21PM >>>
> Make sure that you added it to the index as a stored field, and not
> just indexed.  Look at the Javadoc for Field class to see different
> field types.
>
> Otis
>
> --- ROSHAN NAVENDRA <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > I would like to access the contents field of a document, fo rexample
> >
> > doc(i).get("contents")
> >
> > this should return a String (am i right?) but when I print it out I
> > find that it is a Null. How do I go about accessing the contents of
> > the file????
> >
> > Rosh.
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> >
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Sports - live college hoops coverage
> http://sports.yahoo.com/
>
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>


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

Reply via email to