0

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.

4

1 回答 1

0

也许你会发现很适用:它有效,如果你需要任何额外的建议,你可以问我,我在这里很活跃!:)

基本上,它描述的事情与你正在做的事情大致相同,但它展示了一些你在这里没有做的事情;即,使用构造的 MultiFieldQueryParser 对象来解析输入的搜索词,并使用 BooleanQuery 将它们相加。

于 2013-04-07T19:09:04.190 回答