只檢索網頁內容的Indexer:
Liferary大牛 冷月 指點的,在這裏表示一下感謝。
Indexer indexer = IndexerRegistryUtil.getIndexer(JournalArticle.class);
用categoryID來進行檢索,不用setKeywords的方法:
Indexer indexer = IndexerRegistryUtil.getIndexer(JournalArticle.class);
BooleanQuery fullQuery = BooleanQueryFactoryUtil.create(searchContext);
for (long assetCategoryId : searchContext.getCategoryIds()) {
fullQuery.addTerm("assetCategoryIds", assetCategoryId);
}
BooleanClause booleanClause = BooleanClauseFactoryUtil.create(searchContext, fullQuery, BooleanClauseOccur.MUST.getName());
searchContext.setBooleanClauses(new BooleanClause[] { booleanClause } );
Hits hits = indexer.search(searchContext);