lucenenet-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Heath Aldrich" <>
Subject RE: Switching Analyzer or turn off stemming for specific field?
Date Thu, 14 Feb 2008 20:26:09 GMT
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...


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


-----Original Message-----
From: Min Yin [mailto:yin@AI.SRI.COM] 
Sent: Thursday, February 14, 2008 1:02 PM
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!


View raw message