How can i specify a custom Analyzer for a Field of Document?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How can i specify a custom Analyzer for a Field of Document?

小鱼儿-2
Directory indexDataDir = FSDirectory.open(Paths.get("index_data"));
Analyzer analyzer = MyLuceneAnalyzerFactory.newInstance();
IndexWriterConfig iwc = new IndexWriterConfig(analyzer);
iwc.setOpenMode(OpenMode.CREATE);
iwc.setRAMBufferSizeMB(256.0);
IndexWriter indexWriter = new IndexWriter(indexDataDir, iwc);

like the above code which i use for building index, the problem is, Why i
can only set 1 analyzer for the whole index?

I have a document set, most fields to index is only text type, suited for a
StandAnalyzer or a SmartChineseAnalyzer. But the problem is, i have a
special field which is a KeywordList type, like "A;B;C", which i hope i can
fully control the analyzing step.

How to do this in Lucene?
Reply | Threaded
Open this post in threaded view
|

Re: How can i specify a custom Analyzer for a Field of Document?

Mikhail Khludnev-2
You can check how SolrAnalyzer switches chains across fields.

On Tue, Dec 10, 2019 at 9:41 AM 小鱼儿 <[hidden email]> wrote:

> Directory indexDataDir = FSDirectory.open(Paths.get("index_data"));
> Analyzer analyzer = MyLuceneAnalyzerFactory.newInstance();
> IndexWriterConfig iwc = new IndexWriterConfig(analyzer);
> iwc.setOpenMode(OpenMode.CREATE);
> iwc.setRAMBufferSizeMB(256.0);
> IndexWriter indexWriter = new IndexWriter(indexDataDir, iwc);
>
> like the above code which i use for building index, the problem is, Why i
> can only set 1 analyzer for the whole index?
>
> I have a document set, most fields to index is only text type, suited for a
> StandAnalyzer or a SmartChineseAnalyzer. But the problem is, i have a
> special field which is a KeywordList type, like "A;B;C", which i hope i can
> fully control the analyzing step.
>
> How to do this in Lucene?
>


--
Sincerely yours
Mikhail Khludnev