lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uwe Schindler" <>
Subject RE: [update] adding field with constructor demanding tokenStream fails - Field(name, tokenStream, termVector) BUG
Date Sun, 24 Jul 2011 19:20:55 GMT
The problem with your code is simple: You cannot consume a tokenstream twice (like an iterator),
when you consume it with the System.out.println() loop it can no longer be consumed by the
Indexer. The same happens when you add the same TokenStream to several Fields to index.


Still I don’t understand the whole problem, looks like a XY-problem:  <>



Uwe Schindler

H.-H.-Meier-Allee 63, D-28213 Bremen <> 



From: andrzej_gadek [] 
Sent: Sunday, July 24, 2011 9:11 PM
Subject: [update] adding field with constructor demanding tokenStream fails - Field(name,
tokenStream, termVector) BUG


update ->


I have find out that the problem comes from those constructors:


new Field(name, tokenStream)
new Field(name, tokenStream, termVector)





StandardAnalyzer stAnalyzer = new StandardAnalyzer(Version.LUCENE_30);

TokenStream stStream = stAnalyzer.tokenStream("analizedContent", new StringReader(handler.toString()));

TermAttribute term = stStream.addAttribute(TermAttribute.class);
System.out.println("loop 1");

System.out.print(term.term() + ":");


Field field = new Field("analizedContent", stStream, TermVector.YES);

TokenStream tSV = field.tokenStreamValue();
TermAttribute term2 = stStream.addAttribute(TermAttribute.class);


System.out.println("loop 2");
System.out.print(term2.term() + ":");

System.out.println ("field.readerValue(): " + field.toString());
System.out.println ("field.readerValue(): " + field.readerValue());
System.out.println ("fieldfield.stringValue(): " + field.stringValue());



and now what a get in console:


loop 1
/*and many more ;-)*/

field.readerValue(): indexed,tokenized,termVector<analizedContent:>
loop 2

field.readerValue(): null
fieldfield.stringValue(): null


my comment: after creation of new Field we lose a value of posted tokenStream. So problem
o curse when U want to index pre-analized text, for example with different then default analyzer
(in my case polish one)  


my conclusion: something is not working wright!

Probably nobody will help me so i'm going to find some alternate way to do this. For example
will make String form analyzed text and then use default analyzer to parse it. 




View raw message