lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hostetter <hossman_luc...@fucit.org>
Subject Re: Problem with tokenStreamValue() method in Field class
Date Wed, 06 Feb 2008 20:45:15 GMT

you are running into one of hte problems relating to "Field" being reused 
by both the indexing code and the searching code.

things like the tokenStreamValue() and readerValue() only have meaning on 
Fields that are about to be indexed ... Field objects returned from 
searches will never return data from those methods.

Field objects returned from a search will only ever have the "stored" 
value of a Field, which is available from stringValue() 

: I am slightly confused.
: The following code generates the output below.
: 
: Document doc = hits.doc(i);
: System.out.println(doc.getFields());
: Field f = doc.getField("Text");
: System.out.println(f);
: TokenStream ts = f.tokenStreamValue();
: System.out.println(ts);
: while (true){
: 	Token token = ts.next();
: 	if (token==null) break;
: 	System.out.print(token+" ");
: }
: System.out.println();
: 
: 
: [stored/uncompressed,indexed,tokenized<Title:Infrared Data Association>,
: stored/uncompressed,indexed,tokenized<Type:Text>,
: stored/uncompressed,indexed,tokenized<Text:This is a test>]
: stored/uncompressed,indexed,tokenized<Text:This is a test>
: null
: java.lang.NullPointerException
: at ... (IndexQuerier.java:86)
: ...
: 
: So I am accessing a field which is displayed as "tokenized", but I still
: can't access its "tokenStreamValue()"? Why is that? Is there some way to get
: to tokens? Or did I do something wrong during indexing?
: 
: 
: Regards,
: Mika 
: -- 
: View this message in context: http://www.nabble.com/Problem-with-tokenStreamValue%28%29-method-in-Field-class-tp15048591p15048591.html
: Sent from the Lucene - Java Users mailing list archive at Nabble.com.
: 
: 
: ---------------------------------------------------------------------
: To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
: For additional commands, e-mail: java-user-help@lucene.apache.org
: 



-Hoss


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


Mime
View raw message