你好!
Thanks so much! I will take a try!
Best wishes,
Li Bing
On 8/27/07, Erik Hatcher <[EMAIL PROTECTED]> wrote:
> 你好-
>
> TermQuery is for a specific term, which is typically the end result
> of analysis. It doesn't make sense to use an Analyzer to construct a
> TermQuery. However, you can use an Analyzer yourself to construct
> TermQuery's, just as QueryParser does.
>
> Look at the AnalysisDemo (Java) code in my old article here: http://
> today.java.net/pub/a/today/2003/07/30/LuceneIntro.html
>
> It will show you how to use an Analyzer and walk its TokenStream.
> For each token you can construct the TermQuery of your choice.
>
> Erik
>
>
> On Aug 26, 2007, at 1:20 PM, Li Bing wrote:
>
> > 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
>
>