lucene 多欄位查詢-MultiFieldQueryParser

不知為何就叫呵呵發表於2016-12-16

 

/**
 * 搜尋域加權
 */
Map<String, Float> boosts = new HashMap<>();
boosts.put("title", 1.2f);
boosts.put("author", 1.1f);
boosts.put("content", 1.0f);
/**
 * 多條件之間的關係
 */
BooleanClause.Occur[] flags = {BooleanClause.Occur.SHOULD,
BooleanClause.Occur.SHOULD,
BooleanClause.Occur.SHOULD};
Query query=MultiFieldQueryParser.parse(key, new String[]{"title","author","content"},flags, analyzer);

 

相關文章