i got the following code:
Lucene.Net.Analysis.Analyzer analyzer = new Lucene.Net.Analysis.Standard.StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_29);
var mainQuery = new Lucene.Net.Search.BooleanQuery();
foreach (var str in fields)
{
var parser = new Lucene.Net.QueryParsers.QueryParser(Lucene.Net.Util.Version.LUCENE_29, str, analyzer);
mainQuery.Add(parser.Parse(search +"*"), Lucene.Net.Search.BooleanClause.Occur.SHOULD);
}
Lucene.Net.Search.TopScoreDocCollector collector = Lucene.Net.Search.TopScoreDocCollector.create(21, true);
searcher.Search(mainQuery, collector);
hits = collector.TopDocs().scoreDocs;
and life was good.
until i noticed, that i get results that are also NotActive
.
so i said to myself, ok , no problem, lets add another query to the mainQuery just after the for loop
like so:
var parser2 = new Lucene.Net.QueryParsers.QueryParser(Lucene.Net.Util.Version.LUCENE_29, "StateProperties.IsActive", analyzer);
mainQuery.Add(parser2.Parse("True"), Lucene.Net.Search.BooleanClause.Occur.MUST);
unfortunally, this does not work.
anyone can point me to the right direction of doing this ?
i have read about filters, and even managed to apply one, but then i lose the scores ( well, not really lose, but they are way off the original query ).
i also read about TermQueryWrapper
, but could not find how to implement that ( so i dont know if thats what i need, even due it seems to be the right direction ).
EDIT: i forgot to mention, all the fields in fields
are ANALYZED,
the StateProperties.IsActive
is NOT_ANALYZED
.