Hi Kumar
> Emir , i need all tokens of query in incrementToken() function not only 
> current token 

That was just an example - the point was that you need to set attributes - you 
can read all tokens from previous stream, do whatever needed with them and when 
ready, set attributes and return true. Peeking and looking ahead is just 
convenient method that can be used to decide if you want to emit token from 
your token filter without consuming token from the previous one.
If I got your case right, you want to consume all tokens, concat them, return 
single token and forget about tokens from previous stream. If that’s the case, 
you need something like:

String term = “”;
int pos = posAtt.getPosition();
while (input.incrementToken()) {
     term += “ ” + termAtt.toString(); // better use StringBuffer
 }
termAtt.setValue(term); // or whatever method for setting att value;
posAtt.setPosition(pos);
lenghtAtt.setLength(term.lenght);

return term.length > 0;


Take this as pseudo code.

HTH,
Emir
--
Monitoring - Log Management - Alerting - Anomaly Detection
Solr & Elasticsearch Consulting Support Training - http://sematext.com/



> On 19 Nov 2017, at 21:54, Ahmet Arslan <iori...@yahoo.com.INVALID> wrote:
> 
> 
> Hi Kumar,
> I checked the code base and I couldn't find peek method either. However, I 
> found LookaheadTokenFilter that may be useful to you.
> I figured that this is a Lucene question and you can receive more answers in 
> the Lucene user list.
> Ahmet
> 
> 
>    On Sunday, November 19, 2017, 10:16:21 PM GMT+3, kumar gaurav 
> <kg2...@gmail.com> wrote:  
> 
> Hi friends 
> very much thank you for your replies .
> yet i could not solved the problem .
> Emir , i need all tokens of query in incrementToken() function not only 
> current token .
> Modassar , if i am not ending or closing the stream . all tokens is blank and 
> only last token is indexed .
> Ahmet i could not find peek or advance method :(  
> 
> Please help me guys . 
> 
> On Fri, Nov 17, 2017 at 10:10 PM, Ahmet Arslan <iori...@yahoo.com> wrote:
> 
> Hi Kumar,
> If I am not wrong, I think there is method named something like peek(2) or 
> advance(2).Some filters access tokens ahead and perform some logic.
> Ahmet    On Wednesday, November 15, 2017, 10:50:55 PM GMT+3, kumar gaurav 
> <kg2...@gmail.com> wrote:  
> 
> Hi
> 
> I need to get full field value from TokenStream in my custom filter class .
> 
> I am using this
> 
> stream.reset();
> while (tStream.incrementToken()) {
>     term += " "+charTermAttr.toString();
> }
> stream.end();
> stream.close();
> 
> this is ending streaming . no token is producing if i am using this .
> 
> I want to get full string without hampering token creation .
> 
> Eric ! Are you there ? :)  Anyone Please help  ?
> 
> 

Reply via email to