lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antony Bowesman <>
Subject Re: Not able to search on UN_TOKENIZED fields
Date Mon, 09 Apr 2007 23:46:07 GMT
You can either use KeywordAnalyzer with your QueryParser which will correctly 
handle UN_TOKENIZED fields, but that will use KeywordAnalyzer for all fields.

To use a field specific Analyzer you either need to use PerFieldAnalyzerWrapper 
and preload it with all possible fields and use that as the Analyzer for 
QueryParser.  Alternatively, override QueryParser's getFieldQuery() and then 
choose your Analyzer there based on the field being searched.


Ryan O'Hara wrote:
> Hey Erick,
> Thanks for the quick response.  I need a truly exact match.  What I 
> ended up doing was using a TOKENIZED field, but altering the 
> StandardAnalyzer's stop word list to include only the word/letter 'a'.  
> Below is my searching code:
> String[] stopWords = {"a"};
>             StandardAnalyzer sa = new StandardAnalyzer(stopWords);
>             QueryParser qp = new QueryParser("symbol", sa);
>             Query queryPhrase = qp.parse(symbol.toUpperCase());
>             Hits hits =;
>             String hit;
>             if(hits.length() > 0){
>                 hit = hits.doc(0).get("count");
>                 count = Integer.parseInt(hit);
>             }
> Is the reason it wasn't working due to the fact that I'm passing in a 
> StandardAnalyzer?  I thought that maybe the searching mechanisms would 
> be able to use or not use an analyzer according to what the field.index 
> value is.
> One other question that you may have an answer to:  I'm eventually going 
> to need to alter the stop word list to include all default stop words, 
> except those that match certain criteria.  Can this be done?
> Thanks,
> Ryan

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message