lucene-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From michaeltm <>
Subject Issue PerFieldAnalyzerWrapper with KeywordAnalyzer - MultiFieldQueryParser
Date Mon, 29 Dec 2008 07:14:53 GMT

Hi all, 

I'm new to Lucene and encountered the problem with the searching the exact

This is how I index:
document.Add(new Field("keyword", "hello world", Field.Store.YES,

This is how I try to search for "hello world"
string[] fields = new string[] { "name", "keyword", "shortDescription" };
string strSearchTerm = "hello world";
PerFieldAnalyzerWrapper wrapper = new PerFieldAnalyzerWrapper(new
wrapper.AddAnalyzer("keyword", new KeywordAnalyzer());

QueryParser parser = new MultiFieldQueryParser(fields, wrapper);

Query query = parser.Parse(strSearchTerm);
Hits hits = _Searcher.Search(query);

This returns 0 match.

The problem was that the query returns from QueryParser is: (name:hello
keyword:hello shortDescription:hello) (name:world keyword:world

I've been searching for this issue and someone said that we can only use
TermQuery for search the entire text such as TermQuery termQuery = new
TermQuery(new Term("keyword", strSearchTerm);
Is that correct? 
I'd like to use PerFieldAnalyzerWrapper with KeywordAnalyzer and
MultiFieldQueryParser as I try to search in multiple fields.

Can anyone clarify for me how to use KeywordAnalyzer and
PerFieldAnalyzerWrapper with MultiFieldQueryParser? Any help would be

View this message in context:
Sent from the Lucene - General mailing list archive at

View raw message