Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Lucene: Java-User
Analyzer on query question
 

Index | Next | Previous | View Flat


Bill.Chesky at learninga-z

Aug 2, 2012, 2:09 PM


Views: 575
Permalink
Analyzer on query question

Hi,

I understand that generally speaking you should use the same analyzer on querying as was used on indexing. In my code I am using the SnowballAnalyzer on index creation. However, on the query side I am building up a complex BooleanQuery from other BooleanQuerys and/or PhraseQuerys on several fields. None of these require specifying an analyzer anywhere. This is causing some odd results, I think, because a different analyzer (or no analyzer?) is being used for the query.

Question: how do I build my boolean and phrase queries using the SnowballAnalyzer?

One thing I did that seemed to kind of work was to build my complex query normally then build a snowball-analyzed query using a QueryParser instantiated with a SnowballAnalyzer. To do this, I simply pass the string value of the complex query to the QueryParser.parse() method to get the new query. Something like this:

// build a complex query from other BooleanQuerys and PhraseQuerys
BooleanQuery fullQuery = buildComplexQuery();
QueryParser parser = new QueryParser(Version.LUCENE_30, "title", new SnowballAnalyzer(Version.LUCENE_30, "English"));
Query snowballAnalyzedQuery = parser.parse(fullQuery.toString());

TopScoreDocCollector collector = TopScoreDocCollector.create(10000, true);
indexSearcher.search(snowballAnalyzedQuery, collector);

Like I said, this seems to kind of work but it doesn't feel right. Does this make sense? Is there a better way?

thanks in advance,

Bill

Subject User Time
Analyzer on query question Bill.Chesky at learninga-z Aug 2, 2012, 2:09 PM
    Re: Analyzer on query question simon.willnauer at gmail Aug 3, 2012, 12:42 AM
    RE: Analyzer on query question Bill.Chesky at learninga-z Aug 3, 2012, 6:19 AM
    Re: Analyzer on query question ian.lea at gmail Aug 3, 2012, 6:31 AM
    Re: Analyzer on query question jack at basetechnology Aug 3, 2012, 6:32 AM
        RE: Analyzer on query question Bill.Chesky at learninga-z Aug 3, 2012, 9:53 AM
    RE: Analyzer on query question Bill.Chesky at learninga-z Aug 3, 2012, 9:57 AM
    Re: Analyzer on query question ian.lea at gmail Aug 3, 2012, 10:12 AM
    Re: Analyzer on query question jack at basetechnology Aug 3, 2012, 10:22 AM
        RE: Analyzer on query question Bill.Chesky at learninga-z Aug 3, 2012, 11:55 AM
    Re: Analyzer on query question jack at basetechnology Aug 3, 2012, 1:03 PM
        Re: Analyzer on query question rcmuir at gmail Aug 3, 2012, 1:39 PM
        RE: Analyzer on query question Bill.Chesky at learninga-z Aug 3, 2012, 2:35 PM
    Re: Analyzer on query question ian.lea at gmail Aug 3, 2012, 2:03 PM
    Re: Analyzer on query question jack at basetechnology Aug 3, 2012, 2:48 PM

  Index | Next | Previous | View Flat
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.