lucene-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From michaeltm <n.tm.mich...@gmail.com>
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
text.

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

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
StandardAnalyzer());
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
shortDescription: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
appreciated.

-- 
View this message in context: http://www.nabble.com/Issue-PerFieldAnalyzerWrapper-with-KeywordAnalyzer---MultiFieldQueryParser-tp21199768p21199768.html
Sent from the Lucene - General mailing list archive at Nabble.com.


Mime
View raw message