0

第一部分在这里...


要求:
在多个字段中搜索多个值AND Where Bar.Id == argBar.Id

var parser = new MultiFieldQueryParser
  (new[] { "Name", "Title" }, new SimpleAnalyzer());

parser.???(string.Format("Bar.Id:{0}",argBar.Id)); // o_0

var query = Session.CreateFullTextQuery
   (parser.Parse(searchValue), new[] { typeof(Foo) });

发现这个

Query searchQuery = MultiFieldQueryParser.Parse
  (term, new[] {"title", "description"},  
         new[] {BooleanClause.Occur.SHOULD, BooleanClause.Occur.SHOULD},  
         new StandardAnalyzer());

所以,理论上 - 我应该能够添加argBar.Idand BooleanClause.Occur.Must,但在 Lucene.Net 2.4.0.2 中没有这样的重载。

4

1 回答 1

0
var bq = new BooleanQuery();
bq.Add(parser.Parse(searchValue), BooleanClause.Occur.SHOULD);
bq.Add(new TermQuery
  (new Term("Bar.Id", argBar.Id.ToString()), BooleanClause.Occur.Must);

var r = Session.CreateFullTextQuery(bq, new[] {typeof(Foo)});
//victory
于 2010-02-23T08:58:47.207 回答