lucene版本:3.6
分詞器:ansj_seg-master
在lucene多條件搜索時,想根據兩個字段去做搜索,創建的Query如下所示
Analyzer analyzer = new AnsjAnalysis();
String paramsStr[] = new String[] { "CA0000001", "特惠" };
String keys[] = new String[] {"code", "name" };
BooleanClause.Occur occur[] = new BooleanClause.Occur[] { BooleanClause.Occur.MUST,
BooleanClause.Occur.MUST};
Query query = MultiFieldQueryParser.parse(Version.LUCENE_36, paramsStr, keys,
occur, analyzer);
索引中確定有code為"CA0000001",name為"特惠"的數據,但就是為BooleanClause.Occur.MUST時找不到,如果為BooleanClause.Occur.SHOULD,則可以查詢到那條數據
請問各位要怎麼解決?
should戴表兩個字段中必須有一個..must是必須都存在...你看看大小寫啥的..有可能建索引的時候全都小寫了