I am using Lucene dot net version 2.9 and constructed my query as following (GetQuery method). I could get the results from the same index using Luke tool with the same query. But not via dotnet API. Not sure is that a bug in Lucene.net? or a mistake on my part. Indexing is done with standard analyzer and analyzed all the fields that I am searching.
Note: It is working with Luke with the same index. I am using .net lucene 2.94 not Java Lucene libraries
The query that is working with Luke tool is this:
+(content:polaris location:polaris) +ext:/pdf/xls/doc/docx
Here is the c# code that is NOT working:
private static BooleanQuery GetQuery(string term, string exts)
{
string[] fields = { MetaKeys.Content, MetaKeys.Location };
MultiFieldQueryParser parser = new MultiFieldQueryParser(fields, new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_29));
Query multiFieldQuery = parser.Parse(term);
TermQuery extQuery = new TermQuery(new Term(MetaKeys.Ext, exts));
BooleanQuery combinedQuery = new BooleanQuery();
combinedQuery.Add(multiFieldQuery, BooleanClause.Occur.MUST);
if (extQuery != null)
{
combinedQuery.Add(extQuery, BooleanClause.Occur.MUST);
}
return combinedQuery;
}
And it is used as following
string exts = "/pdf/xls/doc/docx";
BooleanQuery combinedQuery = GetQuery(term, exts);
TopDocs docs = indexSearch.Search(combinedQuery, to);
//resulting in 0 Hits
Note to folks who closed my earlier question: give the original poster a chance (at least 24-hours) to correct it before you are going to close the question.