0
我想在字段1中搜索關鍵字1並且在字段2中搜索關鍵字2 實際上,此代碼完美地工作,但它給了我包含其中一個關鍵字的field1和field2的結果:使用LUCENE庫在多字段中搜索多個關鍵字
StandardAnalyzer analyzer = new StandardAnalyzer(Version.LUCENE_46, stopWordsSet);
String[] fields = { "field1", "field2"};
Float float10 = new Float(10);
Float float5 = new Float(5);
Map<String, Float> boost = new HashMap<String, Float>();
boost.put("nom", float10);
boost.put("email", float10);
MultiFieldQueryParser mfqp = new MultiFieldQueryParser(Version.LUCENE_46,fields, analyzer, boost);
mfqp.setAllowLeadingWildcard(true);
Query userQuery = mfqp.parse("*keyword*");