-->
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.  [ 2 posts ] 
Author Message
 Post subject: Choosing the analyzer
PostPosted: Tue Mar 17, 2009 1:29 pm 
Beginner
Beginner

Joined: Tue Feb 03, 2009 12:29 pm
Posts: 49
I have the fields - make and model - in the Lucene index. These fields are mapped as Index.TOKENIZED using Hibernate search annotations.

I want to do a quick full text search on these 2 fields. In one of the records, the value of make is "Make-1" and model is "Hello World". When I pass the search string "Make-1 Hello", this record is getting matched because I'm using StandardAnalyzer. But I don't want this. I want this record to be matched only if I pass "Make-1 Hello World" or "Make-1 hello world". That is, I want the whole phrase to be matched, but case should not be sensitive. Is there any built in analyzer that works this way? Which existing analyzer can I easily extend to achieve this otherwise?

My code is as follows.
Code:
String[] fields = new String[] { "model", "make"};
MultiFieldQueryParser parser = new MultiFieldQueryParser(fields,
            new StandardAnalyzer());
parser.setDefaultOperator(QueryParser.Operator.AND);
String s = "Make-1 Hello";
Query query = parser.parse(s);


Thanks,
Seema


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 18, 2009 11:35 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

there is no built-in analyzer for that. You can of course write your own or you could use to try to configure an analyzer which suits your needs using the solr analyzer framework. See the Hibernate Search online documentation for this feature. I could imagine that a PatternTokenizerFactory followed by a LowerCaseFilterFactory should do the trick. The pattern to use is (.*) with group=0. I'm just making this up, but it should work.

--Hardy


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.