You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by "Michael J. Prichard" <mi...@mac.com> on 2006/07/29 21:49:30 UTC

PerFieldAnalyzerWrapper use? Analyzer's not being used as expected....

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


Re: PerFieldAnalyzerWrapper use? Analyzer's not being used as expected....

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
Sorry, Otis is right.  I just couldn't see anything else in your code  
that could have been wrong.

	Erik


On Jul 29, 2006, at 11:42 PM, Otis Gospodnetic wrote:

> I think you can reuse them.  Fields should he handled/analyzed  
> sequentially.  I reuse them for some stuff on Simpy.com.
>
> But you may want to clean up that try/catch.  Instead of catching  
> the IOException, you may want to use !IndexReader.indexExists(...)  
> in place of that boolean param to IndexWriter ctor.
>
> Otis
>
> ----- Original Message ----
> From: Michael J. Prichard <mi...@mac.com>
> To: java-user@lucene.apache.org
> Sent: Saturday, July 29, 2006 4:04:23 PM
> Subject: Re: PerFieldAnalyzerWrapper use?  Analyzer's not being  
> used as expected....
>
> Hey Erik,
>
> Will do.  May I ask why?  Out of curiousity.
>
> Thanks,
> Michael
>
> Erik Hatcher wrote:
>
>> 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
>>
>
>
> ---------------------------------------------------------------------
> 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


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


Re: PerFieldAnalyzerWrapper use? Analyzer's not being used as expected....

Posted by "Michael J. Prichard" <mi...@mac.com>.
Awesome!  Thanks!

Otis Gospodnetic wrote:

>Or simpler:
>wr = new IndexWriter(indexDir, aWrapper, !IndexReader.indexExists(indexDir));
>
>----- Original Message ----
>From: Michael J. Prichard <mi...@mac.com>
>To: java-user@lucene.apache.org
>Sent: Sunday, July 30, 2006 1:35:29 PM
>Subject: Re: PerFieldAnalyzerWrapper use?  Analyzer's not being used as expected....
>
>This look better?
>
>        // Check to see if index exists. 
>        // If it doesn't, then set createIndex boolean to true
>        boolean createIndex = false;
>        if (!IndexReader.indexExists(indexDir)) {
>            createIndex = true;
>        }
>
>        // let's set up the index writer
>        wr = new IndexWriter(indexDir, aWrapper, createIndex);
>        wr.setUseCompoundFile(false);
>
>
>
>Otis Gospodnetic wrote:
>
>  
>
>>I think you can reuse them.  Fields should he handled/analyzed sequentially.  I reuse them for some stuff on Simpy.com.
>>
>>But you may want to clean up that try/catch.  Instead of catching the IOException, you may want to use !IndexReader.indexExists(...) in place of that boolean param to IndexWriter ctor.
>>
>>Otis
>>
>>----- Original Message ----
>>From: Michael J. Prichard <mi...@mac.com>
>>To: java-user@lucene.apache.org
>>Sent: Saturday, July 29, 2006 4:04:23 PM
>>Subject: Re: PerFieldAnalyzerWrapper use?  Analyzer's not being used as expected....
>>
>>Hey Erik,
>>
>>Will do.  May I ask why?  Out of curiousity.
>>
>>Thanks,
>>Michael
>>
>>Erik Hatcher wrote:
>>
>> 
>>
>>    
>>
>>>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
>>>
>>>   
>>>
>>>      
>>>


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


Re: PerFieldAnalyzerWrapper use? Analyzer's not being used as expected....

Posted by Otis Gospodnetic <ot...@yahoo.com>.
Or simpler:
wr = new IndexWriter(indexDir, aWrapper, !IndexReader.indexExists(indexDir));

----- Original Message ----
From: Michael J. Prichard <mi...@mac.com>
To: java-user@lucene.apache.org
Sent: Sunday, July 30, 2006 1:35:29 PM
Subject: Re: PerFieldAnalyzerWrapper use?  Analyzer's not being used as expected....

This look better?

        // Check to see if index exists. 
        // If it doesn't, then set createIndex boolean to true
        boolean createIndex = false;
        if (!IndexReader.indexExists(indexDir)) {
            createIndex = true;
        }

        // let's set up the index writer
        wr = new IndexWriter(indexDir, aWrapper, createIndex);
        wr.setUseCompoundFile(false);



Otis Gospodnetic wrote:

>I think you can reuse them.  Fields should he handled/analyzed sequentially.  I reuse them for some stuff on Simpy.com.
>
>But you may want to clean up that try/catch.  Instead of catching the IOException, you may want to use !IndexReader.indexExists(...) in place of that boolean param to IndexWriter ctor.
>
>Otis
>
>----- Original Message ----
>From: Michael J. Prichard <mi...@mac.com>
>To: java-user@lucene.apache.org
>Sent: Saturday, July 29, 2006 4:04:23 PM
>Subject: Re: PerFieldAnalyzerWrapper use?  Analyzer's not being used as expected....
>
>Hey Erik,
>
>Will do.  May I ask why?  Out of curiousity.
>
>Thanks,
>Michael
>
>Erik Hatcher wrote:
>
>  
>
>>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
>>
>>    
>>
>
>
>---------------------------------------------------------------------
>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
>
>  
>


---------------------------------------------------------------------
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


Re: PerFieldAnalyzerWrapper use? Analyzer's not being used as expected....

Posted by "Michael J. Prichard" <mi...@mac.com>.
This look better?

        // Check to see if index exists. 
        // If it doesn't, then set createIndex boolean to true
        boolean createIndex = false;
        if (!IndexReader.indexExists(indexDir)) {
            createIndex = true;
        }

        // let's set up the index writer
        wr = new IndexWriter(indexDir, aWrapper, createIndex);
        wr.setUseCompoundFile(false);



Otis Gospodnetic wrote:

>I think you can reuse them.  Fields should he handled/analyzed sequentially.  I reuse them for some stuff on Simpy.com.
>
>But you may want to clean up that try/catch.  Instead of catching the IOException, you may want to use !IndexReader.indexExists(...) in place of that boolean param to IndexWriter ctor.
>
>Otis
>
>----- Original Message ----
>From: Michael J. Prichard <mi...@mac.com>
>To: java-user@lucene.apache.org
>Sent: Saturday, July 29, 2006 4:04:23 PM
>Subject: Re: PerFieldAnalyzerWrapper use?  Analyzer's not being used as expected....
>
>Hey Erik,
>
>Will do.  May I ask why?  Out of curiousity.
>
>Thanks,
>Michael
>
>Erik Hatcher wrote:
>
>  
>
>>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
>>
>>    
>>
>
>
>---------------------------------------------------------------------
>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
>
>  
>


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


Re: PerFieldAnalyzerWrapper use? Analyzer's not being used as expected....

Posted by Otis Gospodnetic <ot...@yahoo.com>.
I think you can reuse them.  Fields should he handled/analyzed sequentially.  I reuse them for some stuff on Simpy.com.

But you may want to clean up that try/catch.  Instead of catching the IOException, you may want to use !IndexReader.indexExists(...) in place of that boolean param to IndexWriter ctor.

Otis

----- Original Message ----
From: Michael J. Prichard <mi...@mac.com>
To: java-user@lucene.apache.org
Sent: Saturday, July 29, 2006 4:04:23 PM
Subject: Re: PerFieldAnalyzerWrapper use?  Analyzer's not being used as expected....

Hey Erik,

Will do.  May I ask why?  Out of curiousity.

Thanks,
Michael

Erik Hatcher wrote:

> 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
>


---------------------------------------------------------------------
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


Re: PerFieldAnalyzerWrapper use? Analyzer's not being used as expected....

Posted by "Michael J. Prichard" <mi...@mac.com>.
Hey Erik,

Will do.  May I ask why?  Out of curiousity.

Thanks,
Michael

Erik Hatcher wrote:

> 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
>


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


Re: PerFieldAnalyzerWrapper use? Analyzer's not being used as expected....

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
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


Re: PerFieldAnalyzerWrapper use? Analyzer's not being used as expected....

Posted by "Michael J. Prichard" <mi...@mac.com>.
Oh my...disregard this question.  It works...I was instantiating my 
IndexWriter before setting up my Analyzers!!  Dangit...I feel a little 
dumb.  I just switched the order and put the instantiated indexwriter 
last...it works.

Thanks,
Michael

P.S.  I feel somewhat silly!

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