The try…finally pattern in the previous example must be followed. If result sets are left unclosed they hold on to the underlying files in the Lucene index. Although merging can go ahead, the files no longer required after the merge will most likely not be deleted. The number of directories associated with the index will rise and no merged index directories will be deleted, so the disk space taken up by the index will also rise. Restarting will clean up any unused directories (in later versions of Alfresco which includes all the latest supported versions). If the code is not fixed to follow the required pattern the issue will recur.
必须遵循前面示例中的try…finally模式。如果结果集未关闭,则保留Lucene索引中的基础文件。尽管合并可以继续进行,但合并后不再需要的文件很可能不会被删除。与索引关联的目录数量将增加,并且不会删除合并的索引目录,因此索引占用的磁盘空间也将增加。重新启动将清除所有未使用的目录(在Alfresco的更高版本中,包括所有最新支持的版本)。如果代码没有按照所需的模式修复,则问题将再次出现。
At some point the Lucene result set will get bound to the transaction and closed automatically after the transaction commits. However it still makes sense to execute a query using the implicit transactions on the SearchService. In this case the result set returned may not be attached to a transaction and the try…finally pattern is required.
在某个时刻,Lucene结果集将绑定到事务,并在事务提交后自动关闭。但是,使用SearchService上的隐式事务执行查询仍然是有意义的。在这种情况下,返回的结果集可能不会附加到事务,而try…finally模式是必需的。