-->
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: StandardAnalyzer and comma separated text
PostPosted: Tue Jul 21, 2009 4:55 am 
Beginner
Beginner

Joined: Tue Feb 03, 2009 12:29 pm
Posts: 49
hi,

I need to perform a full text search on 2 fields make and model. The below code is used for that. The query generated is
Query =+(make:ford model:ford) +(make:fusion model:fusion)
This fits our requirements. However, if the quickSearchText has no white space after the comma, this does not work.
In this case, the query generated is Query =make:"ford fusion" model:"ford fusion"
Why does this happen? What is the work around for this problem? Can I extend StandardAnalyzer to change this behavior?
Code:
        String quickSearchText = "Ford, Fusion";
        String[] fields = new String[]{"make", "model"};
        MultiFieldQueryParser parser = new MultiFieldQueryParser(fields, new StandardAnalyzer());
        parser.setDefaultOperator(QueryParser.Operator.AND);
        try{
        org.apache.lucene.search.Query query = (org.apache.lucene.search.Query) parser.parse(quickSearchText);
        System.out.println("Query ="+query);


Thanks,
Seema


Top
 Profile  
 
 Post subject: Re: StandardAnalyzer and comma separated text
PostPosted: Tue Jul 21, 2009 9:27 pm 
Newbie

Joined: Wed Jul 15, 2009 12:34 pm
Posts: 18
This is just a guess, but I think the StandardAnalyzer recognizes "ford,fusion" as a single word, since there are no white spaces to separate the two words. A simple workaround is to "fix" quickSearchText by including a white space after the comma, before passing it to the parser.


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.