lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <e...@ehatchersolutions.com>
Subject Re: PerFieldAnalyzerWrapper use? Analyzer's not being used as expected....
Date Sat, 29 Jul 2006 19:56:15 GMT
I think you should use a new instance of each analyzer for each  
field, not reuse instances.  Other than that, your usage is fine.

	Erik


On Jul 29, 2006, at 3:49 PM, Michael J. Prichard wrote:

> So I have the following code...
>
> // let's get our SynonymAnalyzer
> SynonymAnalyzer synAnalyzer = getSynonymAnalyzer();
> // let's get our EmailAnalyzer
> EmailAnalyzer emailAnalyzer = getEmailAnalyzer();
>
> // set up perfieldanalyzer
> PerFieldAnalyzerWrapper aWrapper = new PerFieldAnalyzerWrapper(new  
> StandardAnalyzer());           aWrapper.addAnalyzer("subject",  
> synAnalyzer);
> aWrapper.addAnalyzer("content", synAnalyzer);
> aWrapper.addAnalyzer("from", emailAnalyzer);
> aWrapper.addAnalyzer("to", emailAnalyzer);
> aWrapper.addAnalyzer("cc", emailAnalyzer);
> aWrapper.addAnalyzer("bcc", emailAnalyzer);
>
> // create the writer
> try {
>    wr = new IndexWriter(indexDir, aWrapper, false);
>    wr.setUseCompoundFile(false);
> } catch (IOException iox) {
>    // means it ain't there
>    wr = new IndexWriter(indexDir, aWrapper, true);
>    wr.setUseCompoundFile(false);
> }
>
> -----
>
> When I add a Document to the IndexWriter it does not seem to use  
> the analyzer's I want it too.  Just uses StandardAnalyzer for  
> everythign!  Is this the correct way to use PerFieldAnalyzerWrapper?
>
> Thanks,
> Michael
>
> P.S.  I am using Lucene 2 libs.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message