首页 新闻 会员 周边 捐助

lucene 要完成and or 查询怎么弄?

0
悬赏园豆:50 [已关闭问题] 关闭于 2010-07-30 13:07

完成功能: keyword=='led'  and (categoryid1 = "200010414596" orcategoryid2 = "200010414596" or categoryid3 = "200010414596" )

问题补充: 我现在是这样做的,有错,不知怎么改: if (!string.IsNullOrEmpty(keyword)) { //lucene 特殊字符 keyword = Regex.Replace(keyword, replacePattern, new MatchEvaluator(ReplaceSpecial)); if (!Regex.IsMatch(keyword, pattern)) { BooleanQuery.SetMaxClauseCount(10000); //默认为1024; keyword = keyword + "*"; } QueryParser parserkeyword = new QueryParser("KeywordIndex", new StandardAnalyzer()); Query querykeyword = parserkeyword.Parse(keyword); booleanQuery.Add(querykeyword, BooleanClause.Occur.MUST); } if (!string.IsNullOrEmpty(electroniccategoryid)) { //根据关键字构造一个数组 String[] key = new String[] { electroniccategoryid }; //同时声明一个与之对应的字段数组 String[] fields = { "CategoryID1", "CategoryID2", "CategoryID3", "CategoryID4", "CategoryID5" }; //声明BooleanClause.Occur[]数组,它表示多个条件之间的关系 Lucene.Net.Analysis.Analyzer analyzer = new Lucene.Net.Analysis.Analyzer(); BooleanClause.Occur[] flags = new BooleanClause.Occur[] { BooleanClause.Occur.SHOULD }; //用MultiFieldQueryParser得到query对象 Query queryCategoryID = MultiFieldQueryParser.Parse(key, fields,null); booleanQuery.Add(queryCategoryID, BooleanClause.Occur.MUST); }
fobmqj的主页 fobmqj | 初学一级 | 园豆:64
提问于:2010-07-30 12:12
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册