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 Furash Gary <fu...@mcao.maricopa.gov> on 2006/07/10 17:56:04 UTC

How do you use a different analyzer by field?

Maybe I'm approaching this wrong (apologies) and didn't search correctly
through the archives (mia culpa), but...

If I want to apply a different analyzer to different fields in the
document, how do I do that?  It seems like when you create the index you
pass it an analyzer, and that's the one you're stuck with for any field
added to a document added to the index.  However, for field A, (a type
of case number) I might want to do X, for field B, I might want to do Y.
I could put all this in a bunch of if statements in the analyzer, but
that seems sort of odd - well, not if the assumption of the lucene
creators is that you're always indexing a single coherent real-world
document (which it may have been).

Thanks in advance.

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


Re: How do you use a different analyzer by field?

Posted by Otis Gospodnetic <ot...@yahoo.com>.
Use PerFieldAnalyzerWrapper

----- Original Message ----
From: Furash Gary <fu...@mcao.maricopa.gov>
To: java-user@lucene.apache.org
Sent: Monday, July 10, 2006 11:56:04 AM
Subject: How do you use a different analyzer by field?

Maybe I'm approaching this wrong (apologies) and didn't search correctly
through the archives (mia culpa), but...

If I want to apply a different analyzer to different fields in the
document, how do I do that?  It seems like when you create the index you
pass it an analyzer, and that's the one you're stuck with for any field
added to a document added to the index.  However, for field A, (a type
of case number) I might want to do X, for field B, I might want to do Y.
I could put all this in a bunch of if statements in the analyzer, but
that seems sort of odd - well, not if the assumption of the lucene
creators is that you're always indexing a single coherent real-world
document (which it may have been).

Thanks in advance.

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