-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: custom analyzer for searching and indexing.
PostPosted: Fri Feb 15, 2013 5:15 pm 
Newbie

Joined: Thu Jan 12, 2006 4:35 pm
Posts: 13
I have setup a custom analyzer and in hibernate.cfg.xml i have this

Code:
        <property name="hibernate.search.analyzer">com.workscape.hibernate.search.analyzer.ASCIIFoldingAnalyzer</property>


before this if search with "Mun" i couldn't find the person whose name is "Muñiz" but i was finding the person if i typed "Muñ" for the search criteria.
after my custom analyzer the issue is reversed, seems like i need to attach the analyzer to the indexing process too, is that true? if yes, how do i do that? i thought setting the property above will take care of indexing and searching.

I want to be able find that person with both the strings 'mun' or 'muñ', is it possible?

here is my analyzer.

Code:
public class ASCIIFoldingAnalyzer extends Analyzer {

    private static final Log log = LogFactory.getLog(ASCIIFoldingAnalyzer.class);

    @Override
    public TokenStream tokenStream(String fieldName, Reader reader) {
        TokenStream result = null;
        try {
            result = new StandardTokenizer(Version.LUCENE_31, reader);
            result = new StandardFilter(Version.LUCENE_31, result);
            result = new LowerCaseFilter(Version.LUCENE_31, result);
            result = new StopFilter(Version.LUCENE_31, result, StopAnalyzer.ENGLISH_STOP_WORDS_SET);
            result = new ASCIIFoldingFilter(result);
        } catch (Throwable t) {
            log.warn("Error during filtering ", t);
        }
        if(log.isDebugEnabled()) {
            log.debug("Filtered : " + reader.toString());
        }
        return result;
    }
}


Thanks
Srikanth


Last edited by smadarapu on Fri Feb 15, 2013 11:27 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: custom analyzer for searching and indexing.
PostPosted: Fri Feb 15, 2013 6:04 pm 
Newbie

Joined: Thu Jan 12, 2006 4:35 pm
Posts: 13
BTW: I am using hibernare 3.6.7 and 3.4.1 for search analyzers.


Top
 Profile  
 
 Post subject: Re: custom analyzer for searching and indexing.
PostPosted: Mon Feb 18, 2013 3:07 pm 
Newbie

Joined: Thu Jan 12, 2006 4:35 pm
Posts: 13
it turned out that we are adding a '*' to the search string (before we had the custom analyzer) and by adding any wildcards, the analyzer wont be used at all. See http://docs.jboss.org/hibernate/search/3.4/reference/en-US/html_single/#search-query-querydsl

I also needed to use the custom analyzer when creating a QueryParser, which i didn't do.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.