lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From luther blisset <sabri.br...@gmail.com>
Subject Removing diacritics with ISOLatin1AccentFilter
Date Fri, 24 Jul 2009 09:41:45 GMT

Hi folks,
I just upgrading Hibernate Search library of my app and so I had to upgrade
Lucene too and pass from 2.2 to 2.4 version.
In Lucene 2.4 the ISOLatin1AccentFilter class has changed and I can't figure
how it works.
I use a TwoWayFieldBridge to index the data and this is my set method:

public void set(String s, Object o, Document document, Field.Store store,
Field.Index index, Float aFloat){

	//MyObject has a field name
        MyObject objectToIndex;

	//casting from Object to MyObject
	try{
            objectToIndex = MyObject.class.cast(o);
        }catch(ClassCastException cEx ){}



        if (objectToIndex.getName() != null) {
            
            ISOLatin1AccentFilter filter = new ISOLatin1AccentFilter(new
StandardTokenizer(new StringReader(objectToIndex.getName())));
            filter.removeAccents(objectToIndex.getName().toCharArray(),
objectToIndex.getName().length());
            Field name = new Field( "name",
String.valueOf(objectToIndex.getName()).toLowerCase() , Field.Store.YES,
Field.Index.UN_TOKENIZED );

            document.add(name);
        }
}


but it doesn't work. And if pass an accented word for the property
objectToIndex.getName(), it remains with accent :(
I think there is something wrong in my code when I create the new instance
of ISOLatin1AccentFilter  but I can' t get it works properly.
Could someone help me?
thanks a lot
-- 
View this message in context: http://www.nabble.com/Removing-diacritics-with-ISOLatin1AccentFilter-tp24641618p24641618.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


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