Question

Part I here...


Requirement:
search by multiple values in multiple fields 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) });

Found this:

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

So, theoretically - i should be able to add argBar.Id and BooleanClause.Occur.Must, but there isn't such an overload in Lucene.Net 2.4.0.2.

Was it helpful?

Solution

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top