我有一個帶有三個字段(userId,title,description)的索引對象。我想查找標題或描述包含給定關鍵字的特定用戶的所有對象。如何使用lucene API(AND(b OR c))創建嵌套布爾查詢?
我有這樣的事情(不過這顯然是錯誤的):
WildcardQuery nameQuery = new WildcardQuery(new Term("name", filter.getSearch()));
WildcardQuery descQuery = new WildcardQuery(new Term("description", filter.getSearch()));
TermQuery userQuery = new TermQuery(new Term("user_id", u.getId()+""));
BooleanQuery booleanQuery = new BooleanQuery();
booleanQuery.add(new BooleanClause(name_query, Occur.SHOULD));
booleanQuery.add(new BooleanClause(desc_query, Occur.SHOULD));
booleanQuery.add(new BooleanClause(user_query, Occur.MUST));
如何を修改代碼以獲得用正確的ID和在標題或描述搜索短語中的所有對象?