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.
Antony
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 = searcher.search(queryPhrase);
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]