我已将产品的showonhomepage值存储为
doc.Add(new Field("ShowOnHomePage", p.ShowOnHomePage.ToString(), Field.Store.YES, Field.Index.ANALYZED));
尝试根据下面的参数获得结果
if (categoryId != 0)//this filter is working well
{
TermQuery catQuery = new TermQuery(new Term("CategoryId", categoryId.ToString()));
BooleanQuery innerBooleanQuery = new BooleanQuery();
innerBooleanQuery.Add(new BooleanClause(catQuery, Occur.SHOULD));
finalQuery.Add(innerBooleanQuery, Occur.MUST);
}
//Following filter gives result of both products i.e with ShowOnHomePage true or false
TermQuery showOnHomePageQuery = new TermQuery(new Term("ShowOnHomePage", true.ToString()));
finalQuery.Add(showOnHomePageQuery, Occur.MUST);
任何帮助?
答案 0 :(得分:2)
进行小编辑后
TermQuery showOnHomePageQuery = new TermQuery(new Term("ShowOnHomePage", true.ToString().ToLower()));