I tried. But it still doesn't work.

Thanks so much!
LB

On Tue, Aug 25, 2009 at 1:20 AM, [email protected]<[email protected]> wrote:
> It is due to :
>
> booleanQuery.Add(termQuery, BooleanClause.Occur.MUST);
>
> Change it to
>
> booleanQuery.Add(termQuery, BooleanClause.Occur.SHOULD);
>
> and you'll see same results.
>
>
> Li Bing:
>>
>> Dear all,
>>
>> (The codes in the previous email have something specific in my
>> applications. I made changes in this email)
>>
>> I tried to search using two approaches, Query and BooleanQuery. To my
>> surprise, the two behaves different on the same index? Or I made
>> something wrong?
>>
>> On the same index, Query can get results whereas BooleanQuery get NOTHING.
>> Why?
>>
>> The codes are shown as follows.
>>
>> Using Query,
>>
>>       ......
>>       IndexSearcher searcher = new IndexSearcher(fsDirectory);
>>       Analyzer chineseAnalyzer = new ChineseAnalyzer();
>>       QueryParser queryParser = new QueryParser(searchField,
>> chineseAnalyzer);
>>       Query query = queryParser.Parse(searchKeyword);
>>       Hits results = searcher.Search(query);
>>       ......
>>
>> Using BooleanQuery,
>>
>>       ......
>>       IndexSearcher searcher = new IndexSearcher(fsDirectory);
>>       Term term = new Term(searchField, searchKeyword);
>>       TermQuery termQuery = new TermQuery(term);
>>       BooleanQuery booleanQuery = new BooleanQuery();
>>       booleanQuery.Add(termQuery, BooleanClause.Occur.MUST);
>>       Hits results = searcher.Search(booleanQuery);
>>       ......
>>
>> I think the codes should be correct. But why do they get different
>> results on the same index?
>>
>> Thanks so much for your help!
>> LB
>>
>>
>>
>
>

Reply via email to