lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ahmet Arslan <>
Subject Re: Analyzer: Access to document?
Date Wed, 04 Feb 2015 15:15:34 GMT
Hi Ralf,

Does following code fragment work for you?

* Modified from :
public List<String> getAnalyzedTokens(String text) throws IOException {

final List<String> list = new ArrayList<>();
try (TokenStream ts = analyzer().tokenStream("field", new StringReader(text))) {

final CharTermAttribute termAtt = ts.addAttribute(CharTermAttribute.class);
ts.reset(); // Resets this stream to the beginning. (Required)
while (ts.incrementToken())

ts.end();   // Perform end-of-stream operations, e.g. set the final offset.
return list;

On Wednesday, February 4, 2015 2:45 PM, Ralf Bierig <> wrote:
Hi all,

an Analyzer has access to content on a per-field level by overwriting 
this method:

protected TokenStreamComponents createComponents(String fieldName, 
Reader reader);

Is it possible to get to the document? I want to collect the text 
content from the entire document within my analyzer to be processed by 
an external component.


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

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

View raw message