lucenenet-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Min Yin <...@AI.SRI.COM>
Subject Re: Switching Analyzer or turn off stemming for specific field?
Date Fri, 15 Feb 2008 21:11:06 GMT
That works great. Thanks Heath!

Min

Heath Aldrich wrote:
> Hi Min, 
>
> Here is a bit of code I use to do that... it is part of my custom Analyzer class
> You can see that if we are dealing with a field named item_code, then we use the keyword
tokenizer... otherwise, we do snowball and whitespace...
>
>
> <snip>
>
> Public Class MyAnalyzer
>     Inherits Analyzer
>
>     Public Overloads Overrides Function TokenStream(ByVal fieldName As String, ByVal
reader As TextReader) As TokenStream
>
> 		'if we're dealing with an item code field, treat it with the keyword tokenizer
>         If fieldName = "item_code" Then
>             Return New Lucene.Net.Analysis.KeywordTokenizer(reader)
>         Else
> 			'treat these fields with whitespace and snowball
>             Dim x = New Lucene.Net.Analysis.WhitespaceTokenizer(reader)
>             Return New Lucene.Net.Analysis.Snowball.SnowballFilter(GetSyns(x), "English")
>         End If
>
>     End Function
>
> End Class
>
> </snip>
>
> -----Original Message-----
> From: Min Yin [mailto:yin@AI.SRI.COM] 
> Sent: Thursday, February 14, 2008 1:02 PM
> To: lucene-net-user@incubator.apache.org
> Subject: Switching Analyzer or turn off stemming for specific field?
>
> Hello there!
>
> I have a question regarding the Snowball stemming analyzer. We are 
> generally happy with the fuzzy search it provides, but there're cases we 
> want an exact match, for example, a person's name.
>
> I wonder if it's possible to use multiple analyzers and switch between 
> them for different lucene fields, or if there is a way to temporarily 
> turn off the stemming when we want.
>
> Thanks in advance!
>
> Min
>
>
>   


Mime
View raw message