lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <>
Subject Re: null pointer exception when try to get contents out of hits
Date Tue, 29 Mar 2005 02:30:14 GMT
On Mar 28, 2005, at 5:35 PM, Xiaozheng Ma wrote:
> Hi guys,
> I indexed the file by title and contents such as:
>    document.add(Field.Text("title", file.getTitle()));
>    document.add(Field.Text("contents", file.getTextContents()));
> 	//the getTextContents() return the Reader type obj
> so far so good. I was able to search on both title and contents.
> Now since the title changed, I need to update the index(the contents
> never change). Instead of calling file.getTextContents() again, I 
> figure
> that it maybe faster if I can get the reader (of contents field) back
> from the search hits(the original file could be huge).

You're out of luck here.  Field.Text(String, Reader) is an unstored 
field, so the contents are not in the index.

There is one trick - you can access the terms that came from the 
analysis process over that text, but it is very unlikely to be the 
original contents.  See how Luke does this if you need to go to that 


>   While <hits.doc(0).get("title")> returns title as expected
> BUT the call on 'contents' returns null and raises null pointer
> exception on further action.
> Both
> 	hits.doc(0).get("contents")
> 	hits.doc(0).getField("contents")
> return null
> I tested that I could search on 'contents:something' and it returned 
> the
> expected hit.
> I am using the Lucene one release before the current release. My
> question is: is it possible to get the Reader object (or contents text
> string in that matter) back after I get the hit and how.
> Thank you in advance!
> Xiaozheng
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

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

View raw message