In this example, Lucene is used to find all nodes of the content type (using the first Lucene query example).
It assumes you have access to the ServiceRegistry bean via Spring injection, or some other means.
在本例中,Lucene用于查找内容类型的所有节点(使用第一个Lucene查询示例)。
它假设您可以通过Spring注入或其他方式访问ServiceRegistry bean。

SearchParameters sp = new SearchParameters();
sp.addStore(getStoreRef());
sp.setLanguage(SearchService.LANGUAGE_LUCENE);
sp.setQuery('TYPE:\'{http://www.alfresco.org/model/content/1.0}content\'');
ResultSet results = null;
try {
    results = serviceRegistry.getSearchService().query(sp);
    for(ResultSetRow row : results) {
        NodeRef currentNodeRef = row.getNodeRef();
        ...
    }
} finally {
    if(results != null) {
        results.close();
    }
}

It is important that the results set is closed after use, as some search implementations need this call to release resources.
For example, the Lucene implementation releases IO resources.
使用后关闭结果集是很重要的,因为有些搜索实现需要此调用来释放资源。
例如,Lucene实现释放IO资源。

文档更新时间: 2020-02-10 09:21   作者:凌云文档