1
我試圖查詢一些結果使用布爾查詢。但是,查詢不會返回任何結果。Lucene添加額外的過濾器返回沒有結果
這是我正在運行的FilterQuery。即使字段foo包含bar,並且字段foo3包含bar3,也不會返回結果。我有三重檢查了我的領域,以確保這些字段確實存在於索引中。
+(foo:bar foo2:bar2) +foo3:bar3
現在,如果從查詢中刪除+ foo3:bar3,我會正確返回結果。此外foo3:bar3正在編程添加,所以我不解析它。下面是一些相關的代碼
//This code creates the first part of the query.
MultiFieldQueryParser mfqp = new MultiFieldQueryParser(Lucene.Net.Util.Version.LUCENE_29,SearchFields, analyzer);
Query q = mfqp.Parse(query);
BooleanQuery filterquery = new BooleanQuery();
filterquery.Add(q,BooleanClause.Occur.MUST);
//This code creates the second part of the query
Query fq = new TermQuery(new Term("foo3","bar3"));
filterquery.Add(fq, BooleanClause.Occur.MUST);
//Perform the search
ScoreDoc[] hits = isearch.Search(filterquery, null, ResultsToReturn).scoreDocs;
僅供參考,我目前的設置字段進行分析,矢量設置爲With_positions_offsets
確實+ foo3:bar3本身返回任何文件? – bajafresh4life 2010-07-14 16:00:00
如果我修改搜索的方式,它確實會返回文檔。如果MFQP將術語傳遞給booleanquery,那麼它就起作用。但是如果我使用termquery,它會失敗 – 2010-07-14 16:22:43