Hi, all,
I am new in Lucene.NET. Now I use it to build a search engine. But I
notice one problem, that I cannot specify Analyzer when using
TermQuery to create a Query. A sample is shown as follows.
public Hits SearchByMultipleKeywords(string fsDirectory, string
searchType, ArrayList keywordList)
{
IndexSearcher indexSearcher = new IndexSearcher(fsDirectory);
Term term;
TermQuery termQuery;
BooleanQuery booleanQuery = new BooleanQuery();
foreach (string keyword in keywordList)
{
term = new Term(searchType, keyword);
termQuery = new TermQuery(term);
booleanQuery.Add(termQuery, BooleanClause.Occur.MUST);
}
return indexSearcher.Search(booleanQuery);
}
In the above code, how to specify a particular Analyzer, such as
ChineseAnalyzer? I have got a way to do that. If so, the above code
does not work with Chinese searching. The only way to achieve
BooleanQuery is to use QueryParser because QueryParser can be
constructed with a ChineseAnalyzer. Is it true?
Thanks so much!
Li Bing