[prev in list] [next in list] [prev in thread] [next in thread] 

List:       solr-dev
Subject:    Re: Override Analyzer.TokenStreamComponents's reader.
From:       Patrick Zhai <zhai7631 () gmail ! com>
Date:       2023-09-18 5:05:50
Message-ID: CA+vuXU5wT5Wr9rGdFZTL+uA=79zHb3NomfUGUpPnk+p6y2ESXA () mail ! gmail ! com
[Download RAW message or body]

Hi MyCoy, according to MIGRATE file
<https://github.com/apache/lucene/blob/main/lucene/MIGRATE.md>

"""
### TokenStreamComponents is now final

Instead of overriding `TokenStreamComponents.setReader()` to customise
analyzer
initialisation, you should now pass a `Consumer<Reader>` instance to the
`TokenStreamComponents` constructor.
"""

Best
Patrick

On Sun, Sep 17, 2023 at 9:26 PM MyCoy Z <mycoy.zhang@gmail.com> wrote:

> Hi, Lucene Dev Community:
>
> In our legacy Lucene7 based code, we have logic like:
> return new TokenStreamComponents(Tokenizer source, TokenStream result) {
>     @Override
>     protected void setReader(Final Reader reader) {
>         // _config.getCharFilterFactory() , this will return an instance
> of org.apache.lucene.analysis.util.CharFilterFactory
>         super.setReader(_config.getCharFilterFactory().create(reader));
>     }
> };
>
> However, in Lucene9.7, Analyzer.TokenStreamComponents.setReader(Reader)
> becomes private (actually I don't see this method being called anywhere in TokenStreamComponents,
> not sure why it is still there).
> Moreover, Tokenizer.setReader(Reader) is final, and cannot be overridden.
>
> So, could anyone help me to understand what is the best approach to
> migrate that piece of legacy code to L9.
> An example will also be very helpful.
>
> Thanks
>
>

[Attachment #3 (text/html)]

<div dir="ltr">Hi MyCoy, according to <a \
href="https://github.com/apache/lucene/blob/main/lucene/MIGRATE.md">MIGRATE \
file</a><div><br></div><div>&quot;&quot;&quot;</div><div>### TokenStreamComponents is \
now final<br><br>Instead of overriding `TokenStreamComponents.setReader()` to \
customise analyzer<br>initialisation, you should now pass a `Consumer&lt;Reader&gt;` \
instance to the<br>`TokenStreamComponents` \
constructor.<br></div><div>&quot;&quot;&quot;</div><div><br></div><div>Best</div><div>Patrick</div></div><br><div \
class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Sep 17, 2023 at \
9:26 PM MyCoy Z &lt;<a \
href="mailto:mycoy.zhang@gmail.com">mycoy.zhang@gmail.com</a>&gt; \
wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><font \
size="4">Hi, Lucene Dev Community:</font><div><font \
size="4"><br></font></div><div><font size="4">In our legacy Lucene7 based code, we \
have logic like:</font></div><div><font size="4" \
style="background-color:rgb(252,229,205)">return new  TokenStreamComponents(Tokenizer \
source, TokenStream result) {</font></div><div><font size="4" \
style="background-color:rgb(252,229,205)">       <a class="gmail_plusreply" \
id="m_-7951221056243901881plusReplyChip-0">@Override</a></font></div><div><font \
size="4" style="background-color:rgb(252,229,205)">      protected void \
setReader(Final Reader reader) {</font></div><div><span \
style="background-color:rgb(252,229,205)"><font size="4">            //  </font><span \
style="font-size:large">_config.getCharFilterFactory() , this will return an instance \
of  </span><font size="4">org.apache.lucene.analysis.util.</font><span \
style="font-size:large">CharFilterFactory</span></span></div><div><font size="4" \
style="background-color:rgb(252,229,205)">             \
super.setReader(_config.getCharFilterFactory().create(reader));</font></div><div><font \
size="4" style="background-color:rgb(252,229,205)">      }</font><a \
class="gmail_plusreply"><br></a></div><div><font size="4" \
style="background-color:rgb(252,229,205)">};</font></div><div><font \
size="4"><br></font></div><div><font size="4">However, in Lucene9.7, \
Analyzer.TokenStreamComponents.setReader(Reader) becomes private (actually I \
don&#39;t see this method being called anywhere in  </font><span \
style="font-size:large">TokenStreamComponents, not sure why it is still \
there</span><span style="font-size:large">).</span></div><div><font \
size="4">Moreover, Tokenizer.setReader(Reader) is final, and cannot be overridden.  \
</font></div><div><font size="4"><br></font></div><div><font size="4">So, could \
anyone help me to understand what is the best approach to migrate that piece of \
legacy code to L9.  </font></div><div><font size="4">An example will also be very \
helpful.</font></div><div><font size="4"><br></font></div><div><font \
size="4">Thanks</font></div><div><font size="4"><br></font></div></div> \
</blockquote></div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic